parcelable

Parcelable Inheritance issue with getCreator of heir class

心不动则不痛 提交于 2020-01-15 03:05:32
问题 I have a parcelable class A and B that extends A Example: The class A public abstract class A implements Parcelable { private int a; protected A(int a) { this.a = a; } public int describeContents() { return 0; } public static Creator<A> getCreator() { return CREATOR; } public static final Parcelable.Creator<A> CREATOR = new Parcelable.Creator<A>() { public A createFromParcel(Parcel in) { return new A(in); } public A[] newArray(int size) { return new A[size]; } }; public void writeToParcel

Parcelable Inheritance issue with getCreator of heir class

◇◆丶佛笑我妖孽 提交于 2020-01-15 03:05:02
问题 I have a parcelable class A and B that extends A Example: The class A public abstract class A implements Parcelable { private int a; protected A(int a) { this.a = a; } public int describeContents() { return 0; } public static Creator<A> getCreator() { return CREATOR; } public static final Parcelable.Creator<A> CREATOR = new Parcelable.Creator<A>() { public A createFromParcel(Parcel in) { return new A(in); } public A[] newArray(int size) { return new A[size]; } }; public void writeToParcel

Class X is not abstract and does not implement fun writeToParcel() defined in android.os.Parcelable

你离开我真会死。 提交于 2020-01-13 08:18:10
问题 In my Android app, I want to add a Bundle including a Place object described below to my Intent. Since serializable was slow and not recommended, I preferred Parcelable. Althoug I use Kotlin 1.3.31, I have problems parcelizing some data classes. Example: import android.os.Parcelable import kotlinx.android.parcel.Parcelize @Parcelize data class Place(val street: String, val postal: String, val city: String) : Parcelable and Android Studio complains: Class 'Place' is not abstract and does not

Put an object in Handler message

我是研究僧i 提交于 2020-01-12 02:42:12
问题 I need to download an image from the internet, in a different thread, and then send that image object in the handler message, to the UI thread. I already have this: ... Message msg = Message.obtain(); Bundle b = new Bundle(); b.putParcelable("MyObject", (Parcelable) object); msg.setData(b); handler.sendMessage(msg); And when I receive this message, I want to extract the object: ... public void handleMessage(Message msg) { super.handleMessage(msg); MyObject objectRcvd = (MyObject) msg.getData(

Can I send custom objects to Android Wear?

£可爱£侵袭症+ 提交于 2020-01-12 01:49:32
问题 I am just learning how to develop for Android Wear, I have created a full screen Activity for Smart Watches and in my mobile part of the application I get some JSON data and create a list of custom objects from this. On my mobile app I show the information for these objects in a ListView. On the Wear piece of my application I want to show a limited version of this list, for example the top 3 from the list will be show on my full screen app on the Wearable. My problem is that there doesn't

Is it possible to create a HashMap that is Parcelable on Android?

半世苍凉 提交于 2020-01-10 13:54:09
问题 I am trying to extend HashMap as a Parcelable and I got the syntax to compile, however, at runtime it throws an exception and returns a null pointer trying to un-marshal the data. The sender has to cast to (Parcelable) to resolve ambiguity, however, the receiver complains that is expected Parcelable but found HashMap. Has anyone been successful with this? Is my syntax wrong? Is there a better solution? Following is the code: HomeActivity.java - the sender ContentViewActivity.java - the

GSON deserialize to bundle

ぐ巨炮叔叔 提交于 2020-01-07 01:50:08
问题 How can i deserialize this JSON: "data": { "key1": 11, "key2": { "key3": 22 "key4": 83 "key5": 99 } } to an Android Bundle using GSON library? This is not working: class Model implements Parcelable { private int key1; private Bundle key2; [...] protected Model(Parcel in) { key1 = in.readInt(); [...] key2 = in.readBundle(); } public void writeToParcel(Parcel dest, int flags) { dest.writeInt(key1); [...] dest.writeBundle(key2); } } I don't want to create a key2 model. 回答1: ok, I can write an

Nested object parcel not working

百般思念 提交于 2020-01-07 00:36:34
问题 Hi Guys i am trying to parcel nested object but it gives RuntimeException: Parcel: unable to marshal value.... please help me to solve this problem... Parcel and pojo structure :- Just showing the variables in pojo.. 1) RateRule :- public class RateRule{ private List<Rule> rules = new ArrayList<Rule>(); } 2) Rule :- public class Rule { private String ruleID; private String splOfferId; private String ruleName; private String ruleDescription; private String ruleType; private List<Room> rooms =

Nested object parcel not working

女生的网名这么多〃 提交于 2020-01-07 00:35:33
问题 Hi Guys i am trying to parcel nested object but it gives RuntimeException: Parcel: unable to marshal value.... please help me to solve this problem... Parcel and pojo structure :- Just showing the variables in pojo.. 1) RateRule :- public class RateRule{ private List<Rule> rules = new ArrayList<Rule>(); } 2) Rule :- public class Rule { private String ruleID; private String splOfferId; private String ruleName; private String ruleDescription; private String ruleType; private List<Room> rooms =

Parcelable object that receives passed data coming up null

…衆ロ難τιáo~ 提交于 2020-01-06 18:07:23
问题 I'm working on an Android app that stores contact information, I'm trying to add a feature that when you click on a contact item in the ListView it will send the contact object that implements parcelable over two the second activity. This is Where I send the contact object over to the Contacts Activity. ` @Override protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub final Contact item = (Contact) getListAdapter().getItem(position);