parcelable

Intent and Parcelable object Android

谁说我不能喝 提交于 2019-12-03 07:51:01
Why do I need to parcel my object even if I just need to send it to another thread of the same task? Actually I need to open an activity that will run even on the same thread (the main thread). In other words why didn't Google provide a version of startActivity that take a generic object ad parameteer instead of a bundle to let me start an activity in case I know it is within the same process or (most of the times) even the same thread (the main one)? You don't need to use Parcelable to pass an object from one activity to another. You can just store a reference to the object in a static member

Is using Parcelable the right way to send data between applications?

▼魔方 西西 提交于 2019-12-03 07:44:22
I am trying to understand how to communicate between applications in Android - not just between Activity instances. I set up a 'client' that sends a Messenger obj to a Service (in the Intent sent to the service); the service creates a Message obj and sends it back to the 'client' using messenger.send(message) . This works fine until I try to use the Message.obj to hold an object. I created my own Parcelable class MyParcelable in the service and put it into the message. All works until the message is unmarshalled in the 'client'. The unmarshall fails because the 'client' has no access to the

Nested parcelable object not reading

笑着哭i 提交于 2019-12-03 04:51:56
问题 I'm trying to parcel an object which contains some string/int variables and an object variable. The strings and int's are working, but not the nested object. I understand I would have to it also parcelable, but I'm apparently doing something wrong=. In my nested class, the writeToParcel method gets called (I check with a Log.d() call), but the createFromParcel() doesn't. I end up getting a null object. This is my simplified code: public class MyClass implements Parcelable { public MyClass() {

Can I send custom objects to Android Wear?

…衆ロ難τιáo~ 提交于 2019-12-03 00:53:14
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 seem to be a way to send Parcelable Objects to Android Wear, there is no option to putParcelable in the

Using Parcelable with circular references

亡梦爱人 提交于 2019-12-03 00:20:17
It appears that Parcelable doesn't gracefully handle circular references like Serializable does. In the following example, the Serialization of Bar works just fine, but writing it to a Parcel causes a stackoverflow: I/TestRunner( 1571): java.lang.StackOverflowError I/TestRunner( 1571): at android.os.Parcel.writeParcelable(Parcel.java:1106) I/TestRunner( 1571): at android.os.Parcel.writeValue(Parcel.java:1029) I/TestRunner( 1571): at com.XXX.util.ParcelableTest$Bar.writeToParcel(ParcelableTest.java:209) I/TestRunner( 1571): at android.os.Parcel.writeParcelable(Parcel.java:1106) I/TestRunner(

Does the readInt(), readFloat() etc. of Parcelable know what value they are retrieving?

有些话、适合烂在心里 提交于 2019-12-02 23:51:12
问题 If your class implement parcelable then you know that you need a constructor for the system to construct your class based on the parcel it just received. So a constructor usually like the one below will have to be written and this is where it gets a bit confusing: public myClass(Parcel in){ this.type = in.readInt(); this.size = in.readInt(); } You see, if there is a parameter and these read related methods are called like this: this.type = in.readInt(type); this.size = in.readInt(size); Then

how to pass objects between intents

对着背影说爱祢 提交于 2019-12-02 15:21:54
问题 I have a class that contains data i want to pass it between intents, this class have arraylist that contains another class objects. this is my class public class ParsedData implements Parcelable { public String error; public float protectionLevel; public int protectionLevelColor; public double lastBackup; public boolean compressedType; public Long driveFreeSpaceSize; ArrayList<Item>Items = new ArrayList<Item>(); } class Item { public String name; public float percentage; public int files;

creating parcelable in android from some of the fields of a class

好久不见. 提交于 2019-12-02 11:55:10
i have the following class which i intent to pass from one activity to another: public class Ad extends ListItem implements parcelable{ private String _type; private String _recordID; private String _line1; private String _line2; private String _line3; private String _line4; private String _url; private IOnUiNeedToUpdateListener _listener; private boolean _notActive = false; private String _alertText; private Double _longitude; private Double _latitude; } i want to pass an array of such objects from one activity to another. however, i do not need to pass all fields. is it possible to create a

Parceable Arraylist of objects

岁酱吖の 提交于 2019-12-02 09:53:07
问题 I'm trying to pass an ArrayList of Person Objects from the MainActivity to SecondActivity to print the details of the person in a custom listView adapter. The application runs but it crashes when it reaches startActivity() to the SecondActivity after passing the ArrayList of Persons. Person implements Parcelable public Person(String id, String name) { this.id = id; this.name = name; } public Person(Parcel in) { id = in.readString(); name = in.readString(); } public void writeToParcel(Parcel

Sending Nested Parcelable with Intent

白昼怎懂夜的黑 提交于 2019-12-02 03:22:17
问题 I am trying to send a Parcelable object which also contains another Parcelable object with Intent. However, I am getting NullPointer Exception. Could you please tell me where I am doing wrong? A.java public class A implements Parcelable { private ArrayList<B> var; public A() { this.var = new ArrayList<B>(); } public void addToB(B b) { var.add(b); } public ArrayList<B> getB() { return var; } public void setB(ArrayList<B> b) { this.var = b; } @Override public int describeContents() { return 0;