There are many arguments in my code which can take the value null. It would be helpful if there is a @Nullable and @NonNull annotation like the ones offered in Android via Annotation. Is there an alternative available in Harmony OS? Answer You can use org.jetbrains.annotations.Nullable & org.jetbrains.annotations.NotNull annotations available from jetbrains dependency, implementation ‘org.jetbrains:annotations:20.1.0’
Tag: android
What is the alternative in Harmony OS for function setBackgroundColor() on View class in Android?
I am working on a HarmonyOS project in that I wanted to set the background color of the component. In Android we have a function setBackgroundColor() in the View class, this can be done as shown below. How can I set background color to a component in HarmonyOS? Answer First you have to build an Element using some color, later
DataModel cannot be cast to java.util.ArrayList
I couldn’t find what the problem is. Logcat is saying : “Caused by: java.lang.ClassCastException: com.example.project.model.DataModel cannot be cast to java.util.ArrayList” I tried different solutions but none worked: Parcelable @SuppressWarning Could someone show me what is wrong in my code please? DataModel.Java TableActivity.Java DetailsActivity.Java Answer You are passing object on intent by doing this, and on receiver side, you are expecting
How much 1px is with respect to fp in Harmony OS?
Can anyone tell px:fp ratio or code to convert fp to px. I am building a HarmonyOS application and I want to set the width of a component to 20fp but setWidth​(int width) takes width in px. Answer HarmonyOS provides the AttrHelper tool class to implement conversion between fp and px. AttrHelper.fp2px() For more details, pls kindly refer to this
How to update the the bitmap image inside the FirebaseStorage in android without changing its downloadUrl in the realtimedatabase
I want to update the bitmap image inside the URL without changing its download URL in the real-time database because at uploading for the first time I have uploaded the image in the storage and stored it URL in the real time database now I want to update that image how should I approach this ?? above written code was
I am trying to make android activity with 3 spinners, and third spinner will display options on based of selection of first and second
I am making an activity with 3 spinners, First spinner only have one value for now but second spinner have total of six values. I want populate 3rd spinner on base of items selected on second spinner (because first spinner only have 1 item). Can any one explain how can I do it? I thought about doing it with switch
Unable to add more than one item in a listview
I am working on a tasks app, for which I created a list view that shows list items consitsting of task names, their priority etc. The data given to the list view is from an sqlite database. I, however, am unable to add more than one item to the list. I have no idea why. I have created a method
android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify
After upgrading to android 12, the application is not compiling. It shows “Manifest merger failed with multiple errors, see logs” Error showing in Merged manifest: Merging Errors: Error: android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined.
I am getting an runtime error (Null Pointer Exception) while using ListView in Android Studio
I am making a Task Manager app using ListView to Show all the tasks.But I am getting this error what I think the error is that, I am sending wrong context in my custom adapter in MainActivity.java file My custom Adapter is My Xml file for activity Main is My custom layout file is My Data class is I am
Update default Content-Type for multipart form-data request in Android
We are currently using okhttp3 and retrofit2 in Android to make an network api call of type POST with multipart/form-data, the api request and response are as shown below If you observe, the request header Content-Type has “multipart/form-data; boundary=xxxxxx-xxxx-xxx….” Following is the code I’m facing an issue with sending the customised request header Content-Type as “multipart/form-data; **charset=utf-8;** boundary=xxxxx-xxxxx-x…..” basically i