parcelable

Overriding onSaveInstanceState

让人想犯罪 __ 提交于 2020-02-02 10:57:10
问题 I'm trying to come to grips with the onSaveInstanceState method in class View (not the one in class Activity). That method does return a Parcelable. I derived my own View from ViewGroup and overrode that method to save my own state. But when the state was to be saved I got an exception: java.lang.IllegalStateException: Derived class did not call super.onSaveInstanceState() That is true enough, but simply calling that method doesn't seem enough to me. So how should I do this? If the method

android.os.BadParcelableException ClassNotFoundException when unmarshalling: inner class

主宰稳场 提交于 2020-01-30 05:43:47
问题 I have a parent class called OuterClass , which contains a List of objects of type InnerClass , which is a static inner class of OuterClass . The static inner class implements Parcelable . I am running into this error: Caused by android.os.BadParcelableException ClassNotFoundException when unmarshalling: com.example.OuterClass.InnerClass android.os.Parcel.readParcelableCreator + 2535 (Parcel.java:2535) android.os.Parcel.readParcelable + 2461 (Parcel.java:2461) android.os.Parcel.readValue +

Android - passing hashmap through intent

谁说胖子不能爱 提交于 2020-01-25 11:43:06
问题 I'm trying to pass a Hashmap of custom objects through an intent. I am trying to use parcelable as that's what i read is the correct way to do things in android (i.e. parcelable over serializable). However, when i try and get the hashmap using getParcelable, it can't find my hashmap in the intent, but getSerializable can. Is it OK to use serializable for hashmaps? Is this my only option? 回答1: You can of course serialize your map, as long as your Objects are serializable. What you also could

Storage Access Framework - Cannot create file in cloud folder selected with ACTION_OPEN_DOCUMENT_TREE (NextCloud)

不羁岁月 提交于 2020-01-25 08:07:49
问题 I am experimenting with Storage Access Framework. I am using NextCloud platform. This platform supports the ACTION_OPEN_DOCUMENT_TREE intent, that the GDrive app itself does not support yet. My app lets the user select a cloud folder on the provider I decided to connect to NextCloud service. static public void openPickerForFolderSelection(Activity activity, int requestCode) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI

Make a class parcelable which contains Custom object list

心不动则不痛 提交于 2020-01-22 15:25:11
问题 I am getting error while making a list object parsable(i think the error occured while reading the object) here is my code public class TestSample implements Parcelable { int intValue; String stirngValue; private List<DocumentControlPolicy> cpls; @Override public int describeContents() { // TODO Auto-generated method stub return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(intValue); dest.writeString(stirngValue); dest.writeTypedList(cpls); dest.writeList

Use of Parceler with Kotlin data class with constructor for serialization

北战南征 提交于 2020-01-22 10:33:46
问题 Is there a way to use Parceler with Kotlin data classes and constructor for serialization without using @ParcelProperty annotation for each field? If I try and use library like this: @Parcel data class Valve @ParcelConstructor constructor(val size: Int) I get Error:Parceler: No corresponding property found for constructor parameter arg0 . But if I add @ParcelProperty("size") it works just fine. Why is that? Update : There are other another way to use this library. I could just remove

Use of Parceler with Kotlin data class with constructor for serialization

混江龙づ霸主 提交于 2020-01-22 10:31:11
问题 Is there a way to use Parceler with Kotlin data classes and constructor for serialization without using @ParcelProperty annotation for each field? If I try and use library like this: @Parcel data class Valve @ParcelConstructor constructor(val size: Int) I get Error:Parceler: No corresponding property found for constructor parameter arg0 . But if I add @ParcelProperty("size") it works just fine. Why is that? Update : There are other another way to use this library. I could just remove

RealmObject AND Parcelable

时光总嘲笑我的痴心妄想 提交于 2020-01-21 04:34:12
问题 I'm new to Realm for Android so I'm not sure I'm approaching this the right way. I have a class which looks like this: public class Entry extends RealmObject implements Parcelable { ... } The problem is the Parcelable interface contains methods like describeContents() writeToParcel() and RealmObjects aren't supposed to have methods other than getters and setters: Error:(81, 17) error: Only getters and setters should be defined in model classes So my question is: How can I make these two work

RealmObject AND Parcelable

半世苍凉 提交于 2020-01-21 04:34:07
问题 I'm new to Realm for Android so I'm not sure I'm approaching this the right way. I have a class which looks like this: public class Entry extends RealmObject implements Parcelable { ... } The problem is the Parcelable interface contains methods like describeContents() writeToParcel() and RealmObjects aren't supposed to have methods other than getters and setters: Error:(81, 17) error: Only getters and setters should be defined in model classes So my question is: How can I make these two work

RecyclerView adapter of array pojo class with inner array class

限于喜欢 提交于 2020-01-15 09:39:09
问题 This is somewhat confusing albeit I believe it to be simpler than what I think. I have a class called Commodities and a class called Stops, the stops class takes in an array of commodities. All the items inside stops are parsing correctly and if I inspect the contents of the stops class on the debugger I can see that everything is where it should go. The issue lies in knowing what to get from the adapter that will be used to display the contents from the Stops class and its inner Commodities