with OkHttp we can make HTTP request then get response from server then with Gson lib convert response to object we need. this is from Square/OkHttp doc: Its request/response API is designed with fluent builders and immutability. It supports both synchronous blocking calls and async calls with callbacks I rea…
Tag: android
Android ENOENT with some files
I use a Intent to get pictures path and open them into a File. I can open files allocated in “Camera” folder like “/storage/emulated/0/DCIM/Camera/IMG_20160817_232858.jpg”, but I cannot open files in locations like “/storage/emulated/0/Pictures/1634894_.png”. Using file.exi…
Sort function in Java collections
If I have following list of student objects, I need to sort these objects in following order. I have tried following code, I am getting following result. But I need all zero’s should be at last. Answer A better way to sort them with 0 higher than any value is: This will correctly handle the case where o…
Gradle-Wrapper.Properties does not exist (Cordova)
I’ve been having the same problem for two days now, and I can’t seem to get Cordova to do what I want. Background: ~ I have every Android SDK installed on my machine ~ My PATH includes SDK tools and platform-tools, under the filepath the exist on my computer ~ I created an environment variable for…
Making a Snackbar Without a View?
I want to show a snackbar as soon as the user opens the Google Maps activity, but the thing is that there’s no views in the activity to use as the first parameter of the activity (in the findViewById() of Snackbar.make()). What do I put there? Here’s the java class code: Also, here is the activity…
enable Annotation Processors option in Android Studio 2.2
I’m trying to use java 8 in my project and for that I added the jack compiler. After enabling jack I started having problems with libraries that use Annotation Processing and looking in the web I read that I need android studio 2.2 and com.android.tools.build:gradle:2.2.0-alpha6 to compile libraries tha…
Setting up an AnimationListener for an ObjectAnimator
In my program, I have an ObjectAnimator which moves an ImageView from left to right. I am trying to set up a listener which will execute a task when the ObjectAnimator is finished running. Here is the …
get removable sd card path in android
How can i get extSdcard path in android? There are 2 storage, first external storage in which all the phones have it but there is second storage which is called removable storage (micro sdcard). I want to get the path to the micro sdcard in android, how is that possible? Answer Starting from KitKat, you have …
Passing Nullable Values from Activity to Fragment
When passing Strings from an activity to a fragment using I can also pass potential null and receive it in the fragment with I’d also like to pass nullable Floats and Integers but the corresponding putInt() and putFloat() methods don’t allow passing null. I am now passing additional flags as argum…
ThreeTen-Backport error on Android – ZoneRulesException: No time-zone data files registered
I’m using ThreeTen-Backport library for my Android project (because java.time is not yet implemented in android development). When I write LocalDate today=LocalDate.now(); or LocalTime time=LocalTime.now(); I get the following exception: The same line of code works well in another java project I have, w…