Clojure Android HTTP request
Following the question you linked to above, their (maslurp) works in the android Clojure REPL app, if (.setDoOutput) is set to false instead, per this question, AND you wrap the call in a future
(to avoid the android.os.NetworkOnMainThreadException
) :
(defn maslurp [url]
(let [a (new java.io.BufferedReader
(new java.io.InputStreamReader
(.getInputStream (doto (.openConnection (new java.net.URL url))
(.setRequestMethod "GET")
(.setDoOutput false) ; false for GET
(.setUseCaches false)))))]
(loop [r (.readLine a) s ""]
(if (nil? r)
s
(recur (.readLine a) (clojure.string/join [s r]))))))
@(future (maslurp "https://www.google.com"))
What is the preferred way to use clojure for making a mobile app (Android and IOs versions)
Using ClojureScript with React Native is now becoming a great answer to this question:
- Performance of React Native is great.
- Existing React libraries like Om and Reagent work with React Native.
- You can benefit from “learn once, write anywhere” knowledge reuse.
- You benefit from using a stack and language that have significant communities behind them.
And the most compelling reason: React Native allows you to write mobile apps using ClojureScript's strength as a functional language, avoiding the imperative style, mutation, and statefulness.
Can I use Clojure to build a mobile chat application?
Have you looked at Clojurescript? There are definitely possibilities here, though they can get quite involved. One possibility is to use something like react-native or om to actually target the native platforms via javascript.
Probably a bit too advanced to start, but worth being aware of for a broader approach to targeting native platforms with clojure code.
Related Topics
Rotating Image. Animation List or Animated Rotate? (Android)
Help with a Custom View Attributes Inside a Android Library Project
How to Specify Location of Debug Keystore for Android Ant Debug Builds
How to Run Android Studio (Android Sdk Emulator) in a Microsoft Hyper-V Virtual Machine
No Cached Version Available for Offline Mode
How to Capture Key Events from Bluetooth Headset with Android
Register Receiver in a Service
Upload Photo Using Httppost Multipartentitybuilder
To Run Dex in Process, The Gradle Daemon Needs a Larger Heap. It Currently Has Approximately 910 Mb
List View Item Swipe Left and Swipe Right
How to Enable Internal App Sharing for Android
Zipalign - Command Not Found - MAC Terminal
Combining Two Bitmap Image (Side by Side)
Setting Action Bar Title and Subtitle
Android - How to Set Background Color of All Screens
Gradle Sync Failed: Failed to Find Build Tools Revision 24.0.0 Rc1