parcelable

How to pass an array of Address objects to an other Acitvity

戏子无情 提交于 2019-12-10 14:18:41
问题 I'm trying to pass an array of Address objects to another Activity through an Intent object. As the Address class implements the Parcelable interface I try to do the following. I got a List Address object from a Geocoder object, which I convert into a array of Address objects. Then I put this array into the Intent and call the activity. final Address[] addresses = addresseList.toArray(new Address[addresseList.size()]); final Intent intent = new Intent(this, SelectAddress.class); intent

Android Parcel in ViewPager

妖精的绣舞 提交于 2019-12-10 10:44:15
问题 I'm using ViewPager in my app and when I press home button during the interaction with ViewPager , the app crashes and I get this error : 3780-3780/? E/AndroidRuntime: FATAL EXCEPTION: main java.lang.RuntimeException: Parcel: unable to marshal value OrdinaryFragment{42000b70 #0 id=0x7f090005 android:switcher:2131296261:0} at android.os.Parcel.writeValue(Parcel.java:1235) at android.os.Parcel.writeList(Parcel.java:622) at android.os.Parcel.writeValue(Parcel.java:1195) at android.os.Parcel

How to send an object containing drawable objects from one android activity to another using intents?

て烟熏妆下的殇ゞ 提交于 2019-12-10 10:19:30
问题 I've gone through this: How to send an object from one Android Activity to another using Intents? But i'm facing problem in sending images in the object to the other activity. Please help. 回答1: Convert your Drawable to Bitmap and send it to Another Activity. Bitmap bitmap = ((BitmapDrawable)d).getBitmap(); To send, intent.putExtra("Bitmap", bitmap); To Fetch, Bitmap bitmap = (Bitmap)this.getIntent().getParcelableExtra("Bitmap"); 回答2: Well you can't really send images with intents since you

Android - polymorphism and Parcelable

冷暖自知 提交于 2019-12-10 09:24:45
问题 I can't figure out how to use polymorohism when writing/reading from parcel. I understand that I need to implement Parcelable in base class, and also in all derived classes (in the case that subclasses have additional properties that I would want to write into parcel). What I don't understand and what I don't know if it's even possible is - how to read subclass from Parcelable i.e., how do I know what kind of subclass I am reading from parcel. I can do some hack like writing some indicator

How to pass object which contain Bitmap to another activity

蓝咒 提交于 2019-12-10 06:54:40
问题 so I am kind of new in Android Developing, I was trying to make a Sign-up Activity ( UserPrivateInfoSignUpActivity.java ) that load a picture (Bitmap) and create a UserPersona Object that I want to pass into another Activity ( UserGeneralDataSignUpActivity ). I did a research for solutions and somehow I am still unable to pass the Bitmap image although it is already implements Parcelable . Any suggestions? Here is my code (without getters & setters) PersonaUser.java: public class PersonaUser

How to implement Parcelable for a class containing List<List<String>>?

谁说我不能喝 提交于 2019-12-10 02:38:01
问题 I have a working Parcelable implementaion for all the fields in my Parcelable Class apart from List<List<String>> class Employee implements Parcelable { List<List<String>> details; //....... protected Employee(Parcel in) { details = new ArrayList<List<String>>(); // i know this is wrong just posting to clarify in.readList(details, List.class.getClassLoader()); //...... } public void writeToParcel(Parcel dest, int flags) { dest.writeList(details); //..... } public int describeContents() {

What is the use of flags in Parcelable?

隐身守侯 提交于 2019-12-10 01:24:04
问题 I have been writing Parcelable s to Parcel without any focus on flags field, which is a parameter in the method signature and it has worked fine but I have run into an implementation where I can no longer ignore them: public static <K extends Parcelable, V extends Parcelable> void write(Parcel dest, Map<K, V> map, int flags) { if (map == null) { dest.writeInt(-1); } else { Set<Map.Entry<K, V>> entrySet = map.entrySet(); dest.writeInt(entrySet.size()); for (Map.Entry<K, V> entry : entrySet) {

Use Parcelable to pass an object from one android activity to another

社会主义新天地 提交于 2019-12-09 17:48:43
问题 I want to do this class A extends Activity{ private class myClass{ } myClass obj = new myClass(); intent i = new Intent(); Bundle b = new Bundle(); b.putParcelable(Constants.Settings, obj); //I get the error The method putParcelable(String, Parcelable) in the type Bundle is not applicable for the arguments (int, A.myClass) i.setClass(getApplicationContext(),B.class); startActivity(i); } How do I use Parcelable to pass obj to activity B? 回答1: As the error suggests, you need to make your class

Passing a Cursor between processes (Parcelable Cursor)

不问归期 提交于 2019-12-09 13:15:23
问题 I need to pass a Cursor ( SQLiteCursor ) from a service to an application on API 10 , and having hard time finding a decent (and fast) solution. I've seen the CursorWindow class. This is Parcelable but I can't instantiate this class on API 10 to use SQLiteCursor.fillWindow() because it has no valid constructors. CursorWindow(boolean) is deprecated. And even if I got a CursorWindow instance with data from a SQLiteCursor , how do I copy this window into a new Cursor ? What Cursor implementation

Parcelable encounteredClassNotFoundException reading a Serializable object

廉价感情. 提交于 2019-12-09 02:17:29
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(Parcel.java:2008) at android.os.Bundle.unparcel(Bundle.java:208) at android.os.Bundle.getString(Bundle