parcelable

Passing arraylist of custom object to another activity

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 18:14:24
When a cell is clicked the object is added to an array. This array needs to be passed into another activity. For testing purposes I have passed the array that has only one object, the DoctorObject. Then in the next activity I get the name as a string using .getName() and display that in a toast. However the toast is empty. Here is some snippets of the code Object: public class DoctorObject implements Parcelable { private List<Object> mChildrenList; public DoctorObject(String name) { Docname = name; } public DoctorObject (Parcel in){ this.DocPic = in.readInt(); this.Docname= in.readString();

How to use writeStringArray() and readStringArray() in a Parcel

杀马特。学长 韩版系。学妹 提交于 2019-12-08 15:27:04
问题 I recently came across a very stupid (at least from my point of view) implementation inside Androids Parcel class. Suppose I have a simple class like this class Foo implements Parcelable{ private String[] bars; //other members public in describeContents(){ return 0; } public void writeToParcel(Parcel dest, int flags){ dest.writeStringArray(bars); //parcel others } private Foo(Parcel source){ source.readStringArray(bars); //unparcel other members } public static final Parcelable.Creator<Foo>

Android Parcelable readStringArray bad array lengths [closed]

会有一股神秘感。 提交于 2019-12-08 08:59:21
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Can you tell me how to solve this? It throws a bad array length exception and after debugging, I found this method throws the Exception: --------------------------My Code----------------------------------- public class SingleModels implements Parcelable{ public String name; public String[] names ; @Override

Using an ArrayList<String> with a class that extends Parcelable

我与影子孤独终老i 提交于 2019-12-08 08:32:47
问题 I'm having trouble with reading an ArrayList of Strings with a class that implements Parcelable. I want to send 3 ArrayLists of Strings to a Fragment. Another thing I don't understand is how I'd use this class to actually send this data to a Fragment (I read somewhere else that you can use your own parcelable class to do this, but I don't know exactly how). Here is the relevant code, I'll put comments in the places I think I need help. package com.tsjd.HotMeals; import java.util.ArrayList;

Passing arraylist of custom object to another activity

会有一股神秘感。 提交于 2019-12-08 07:16:53
问题 When a cell is clicked the object is added to an array. This array needs to be passed into another activity. For testing purposes I have passed the array that has only one object, the DoctorObject. Then in the next activity I get the name as a string using .getName() and display that in a toast. However the toast is empty. Here is some snippets of the code Object: public class DoctorObject implements Parcelable { private List<Object> mChildrenList; public DoctorObject(String name) { Docname =

getParcelableArrayListExtra return nullpointerexception

孤人 提交于 2019-12-08 07:12:29
问题 I have a problem with getParcelableArrayListExtra and Null Pointer Exception. Working My Activity: /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); fetch = new ArrayList<Custom>(); generateEntries(); Log.i("fetch", fetch.toString()); Intent myIntent = new Intent(this, CustomObject.class); //myIntent.putParcelableArrayListExtra("my", fetch); myIntent.putExtra("my",

Parcelable encounteredClassNotFoundException reading a Serializable object

╄→尐↘猪︶ㄣ 提交于 2019-12-08 05:31:50
问题 I've implemented a class that implements Serializable object. public class SaveMe implements Serializable { private static final long serialVersionUID = 1L; private String someValue1; private String someValue2; } But whenever I try to use it in a Bundle, I get this exception: Parcelable encounteredClassNotFoundException reading a Serializable object at android.os.Parcel.readSerializable(Parcel.java:1951) at android.os.Parcel.readValue(Parcel.java:1822) at android.os.Parcel.readMapInternal

Android - Problem with the Serializable interface

吃可爱长大的小学妹 提交于 2019-12-07 18:29:58
问题 I have been using the Serializable interface to pass an object from one activity to another. I am using putExtra on the sender side and getSerializable on the receiver side. Everything works fine but I have received (for the first time) the following error report: java.lang.RuntimeException: Parcelable encountered IOException reading a Serializable object I don't understand why this exception has been generated since I am using getSerializable and not getParcelable . I know that I should

Passing an object from one application to another in android

99封情书 提交于 2019-12-07 18:06:55
问题 After lot of googeling, I could not find any way to pass a object from one application to other application.Though I know that we can pass object from one activty to other activity using Parcel but how to do this between applications? My object is this public class MyObject { private String name; public String getName() { return this.name; } public void setName(String name) { this.name=name; } } Then how to do this like we do for passing object between activities intent.putExtra("key",new

How to marshal/unmarshal ContentValues to insert generic type into ContentProvider?

大城市里の小女人 提交于 2019-12-07 12:12:17
问题 I want to put a generic POJO into ContentValues and unmarshall it within the ContentProvider. I've been wracking my tiny brain re: Parcelables, ContentValues, and inserting into SQLite Regarding: http://njzk2.wordpress.com/2013/05/31/map-to-contentvalues-abusing-parcelable/ How to write a common code for inserting data in android's Sqlite I've been trying to insert a android.location.Location into SQLite via ContentProvider: Location loc = mLocationClient.getLastLocation(); myParcel = android