The notification did well on virtual device but not on real phone. Did I need to have any user permission? I have no idea to solve this problem 😀 here is my code Answer In real phone, you have to check android version. From Oreo, it changed. So you have to add logic like this.
Tag: android
onCreateOptionsMenu not being called
onCreateOptionsMenu does not get called in a fragment. I have to manually call setHasOptionsMenu(true) in onCreatedView() but this causes the item.itemId be an empty String “” in the onOptionsItemSelected() and therefore i can’t detect which menu item was tapped. I’m currently using th…
what is the best way to show a multiple images in android studio?
I have a multiple images about 600 image I want to use it for page in viewPager. I put it all in drawable but it’s take space what is the best way to store image? Answer Uploading them to a Cloudstorage (or Discord) and then loading the images with their links using Coil or Glide would be a way. As
How to parse JSON data without define array in JSON in Android Studio
I am new in Android I am trying to develop an application which is used to validate ifsc code by entering code in edit text. So in this project, I am using Razorpay JSON to fetch data but when I fetch data it shows in JSON format not readable format. How to convert JSON data in a readable format? My
Set CameraX image capture File path
I set the File path to the following: File file = new File(Environment.getExternalStorageDirectory() + “/” + System.currentTimeMillis() + “.png”); But for some reason when i click on the capture image button, it jumps into the onError and logs the following: onError: androidx.camera.co…
Dynamically add chips to chipgroup
I’m trying to add several chips to the chip group dynamically. The first one appears fine but others do not appear properly. But when I do it using XML it works fine. activity_main.xml In MainActivity.java style.xml standalone_chip.xml Answer In your main activity you are doing like this. Notice you are…
How to make a program show a toast instead of crashing?
I am working on an app. Here’s a small fragment which converts the entered string to a fraction: This works pretty well, provided you enter the number in the correct format. However, if we mess up the format, example, inserted 2 spaces or ‘/’, the app crashes and closes. I want that if the p…
How to come out of EditText when clicked on empty space?
I made an app which gives a dialog when an EditText loses focus. However, the editText doesn’t lose focus even when the keyboard is closed. I want that the editText should lose focus when the keyboard is closed (using the back button) or when we click on empty space (empty space being LinearLayout.) How…
How do I log out of my Google Account in Firebase such when I log in again, I can choose the account I would like to sign in with?
This is my coding in my java class file where my log out button is located at. How do I log out of my Google Account in Firebase in android studio, such that when I log in again, I am allowed to …
Can’t use FileObserver to Observe Files Inside a Folder
I want to observe if any file/folder is added inside /storage/emulated/0/DCIM/Camera using FileObserver in a service, but it didn’t work. Please tell me if there is anything wrong in my code 🙏. Here is the source code: AndroidManifest.xml I added the uses-permission and service tags: LogWatcherService.j…