I am new to kotlin, i have converted some code from java but it seems like there’s something wrong, The R in findViewById(R.id.my_id) is highlighted in red and it shows this message : “Unresolved reference: R”.. I’ve been looking for a solution but i seem not to figure it out, So what …
Tag: android
Accessing BroadCastReceiver in Viewmodel
I am struggling in choosing the right way to pass data from broadcastReceiver to ViewModel and from there I pass data to my Repository and update LiveData. I use FCM push notifications and have local broadCastReceiver which uses ActivityLifecycle. I found that it is bad practice to access ViewModel from Broad…
sum value from any list item in Recyclerview Adapter
This is my CartAdapter code, and in onBindViewHolder it get data from Getter and Setter (Get Cart). My purpose is to sum all of the product prices from all data that shows up in cart fragment. public …
Firebase database Data Retrieve getter error
I was trying to get some data from my Firebase realtime-database as followed generally, but I couldn’t figure out where in the code the problem was. The code is attached: I also use getter: database image here xml all allmedicine find_medicine xml Answer Change your query to – And according to fir…
Get Bitmap using a Target in Picasso
I’m working on movies Android app which get list of movies from an API which provides a poster path for all movies. I want to get the image as Bitmap from the image’s URL to save it as a Bitmap variable in the model class. I want to save the image as blob in the DB to retrieve it directly
Android Room library error: Cannot find getter for field
I get this error but I couldn’t find any solution. I tried many things but still I’m getting this code. My code is: https://justpaste.it/4di3y The error: error: Cannot find getter for field. ( private Long fie_id ) How I can fix it? Answer Instead of Do
Failed to find Platform SDK with path: platforms;android-P
Error:FAILURE: Build failed with an exception. What went wrong: A problem occurred configuring project ‘:app’. Failed to find Platform SDK with path: platforms;android-P Answer Step 1: Open Preferences or Settings in Android studio. Select Android SDK options and Install Android API 28 as selected…
CMake could not find JNI
I created a new Android Studio Project with C++ support and did not add anything to it. The project builds, compiles and runs with CMake. I then added the following two lines of code to CMakeLists.txt at the bottom of the file and I get a CMake build error. And this is the error I get when building the projec…
Why LiveData setValue or PostValue triggers onChange just once in the view?
LiveData setValue should have triggered the onChanged method in the Activity, however it calls only at the first time, after when I try to make paging, it breaks and doesn’t call onChanged anymore, though my response is does successful and I see it in the log. What’s wrong with setValue/postValue?…
java- how to generate a 6 digit random hexadecimal value
I have a scenario in a Android app, where a random hexadecimal value has to be generated with 6 digits. (The range of values can be hexadecimal or integer values). What is the most efficient way to do this? Do I have to generate a random decimal number, and then convert it to hexadecimal? Or can a value be di…