I am trying to replace the ZonedDateTime.toInstant method because it is only available since API 26 for Android. But my app is supposed to support API 19. I want to convert the ZonedDateTime to a Date so i can do something like this: What i want to achieve is the following: I want to calculate the difference …
Tag: android
How to fix Android Cloud Firestore document snapshot
I am checking if the user has made an appointment in the database if not add the user(add a new document which has the user details). The problem with my app is that it runs both AddUser() and AlertUser() functions: Answer What does this code do is checking whether a document with the userIdentity id actually…
Set drawable to the end of the text, in TextView
I want to set the drawable image to the end of the text but it shows the end of the text view. Here is my code Answer You can embed an ImageSpan in a SpannableString and set the TextView to display that. For example:
GlideApp cannot be found
error: cannot find symbol variable GlideApp This is the error I have been getting. I’m using Android studio 3.3.1 and imported these modules for glide. Answer To use generated API in Glide you need to create a class and extend AppGlideModule and use @GlideModule annotation, for example: After this rebui…
FireStore date query not working as expected
I have doc which has a date object. Code to init Firestore: Code to query: I am always getting all the records and looks like the where clause is not getting applied. On Firebase console I see that the endDate is stored as timestamp. Doc from Firebase console: Answer Cloud Firestore queries are immutable, whi…
Can I use deprecated classes?
Will using deprecated classes cause severe problems to the program? What is the meaning of deprecated? Can I still work with deprecated classes? An example for it is the ProgressDialog view in Android. It deprecated from API 26 and the replacement is the ProgressBar view. What happens if I will still use the …
Uninstalling app: “App is part of the following app: …” Why is that?
I realized that my self programmed app shows a strange dialog when I try to uninstall it: Normally if you try to uninstall any other app it says… What have I done wrong? Where do I have to change something? Answer Ok, now I accidentally found out why and when this happens: If you change “android:l…
Why in Android documentation Activity classes have static modifier
If we open android documentation we will see that Activity classes have static modifier: I’m used to declaring Activities without static modifier: What is the reason behind using static modifier in Activity class declaration? UPDATE: The static modifiers have been removed from the documentation. Answer …
Using coroutines in a right way
I am implementing the coroutine for first time. I am following MVP pattern for a simple login app. Here is my code flow – The login button clicked will follow this direction – LoginFragment -> LoginPresenter -> Repository -> APIRepository -> RetrofitInterface The login response will fo…
How to limit multiple image selection from the gallery?
I have implemented adding multiple image selection from the gallery in my project. However, I want to limit the user so he/she can select only 3 images from the gallery. I have implemented selecting multiple images from the gallery like this: How can I achieve this? Thanks. Answer You can get the count of Cli…