parcelable

Android: Pass List<GeoPoint> to another Activity

落爺英雄遲暮 提交于 2019-11-27 11:23:00
问题 I have an ArrayList of type GeoPoint. private List<GeoPoint> points = new ArrayList<GeoPoint>(); I want to pass points to another Activity and retrive the data in that activity. How do I do it? I know I have to use the parcelable but I searched, but could not find a way to pass ArrayLists. 回答1: This function will help you: http://developer.android.com/reference/android/content/Intent.html#putParcelableArrayListExtra(java.lang.String, java.util.ArrayList<? extends android.os.Parcelable>) But

Android: Parcelable.writeToParcel and Parcelable.Creator.createFromParcel are never called

前提是你 提交于 2019-11-27 10:34:04
问题 I'm totally new to posting questions on here, however I have been reading a lot on here for years. Normally I always am able to find my answers by thoroughly searching the web, but this time I am at a loss... After having spent yet another day of trying to figure out why this is not working I decided to ask for help, hoping you guys can give me a few pointers, or better, a solution. The problem: In an Android game I have come to the point where I have to make the application remember its

Parcelable where/when is describeContents() used?

断了今生、忘了曾经 提交于 2019-11-27 10:32:56
Does anyone know where/when this method of a Parcelable is called? @Override public int describeContents() { return 0; } It has to be overriden. But should I consider doing something useful with it? Ognyan There is a constant defined in Parcelable called CONTENTS_FILE_DESCRIPTOR which is meant to be used in describeContents() to create bitmask return value. Description for CONTENTS_FILE_DESCRIPTOR in the API ref is: Bit masks for use with describeContents(): each bit represents a kind of object considered to have potential special significance when marshalled. Which really means: If you need

Pass ArrayList<? implements Parcelable> to Activity

萝らか妹 提交于 2019-11-27 06:58:38
I have searched a few topics but not found a solution to my problem. public class Series implements Parcelable { private String name; private int numOfSeason; private int numOfEpisode; /** Constructors and Getters/Setters have been removed to make reading easier **/ public Series(Parcel in) { String[] data = new String[3]; in.readStringArray(data); this.name = data[0]; this.numOfSeason = Integer.parseInt(data[1]); this.numOfEpisode = Integer.parseInt(data[2]); } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest

RealmList with @Parcelize annotation

ⅰ亾dé卋堺 提交于 2019-11-27 06:26:18
问题 I'm trying to use the new @Parcelize annotation added with Kotlin 1.1.4 with a Realm objet containing a RealmList attribute. @Parcelize @RealmClass open class Garage( var name: String? = null, var cars: RealmList<Car> = RealmList() ) : Parcelable, RealmModel As RealmList is not supported by the annotation and assuming that @Parcelize is there specially to avoid creating methods what would be the solution to support RealmList ? Thanks in advance 回答1: EDIT: Using the power of Type Parcelers and

Extract notification text from parcelable, contentView or contentIntent

≯℡__Kan透↙ 提交于 2019-11-27 05:57:13
So I got my AccessibilityService working with the following code: @Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { List<CharSequence> notificationList = event.getText(); for (int i = 0; i < notificationList.size(); i++) { Toast.makeText(this.getApplicationContext(), notificationList.get(i), 1).show(); } } } It works fine for reading out the text displayed when the notifcation was created (1) . The only problem is, I also need the value of (3) which is displayed when the user opens the

How to read/write a boolean when implementing the Parcelable interface?

廉价感情. 提交于 2019-11-27 05:46:24
I'm trying to make an ArrayList Parcelable in order to pass to an activity a list of custom object. I start writing a myObjectList class which extends ArrayList<myObject> and implement Parcelable . Some attributes of MyObject are boolean but Parcel don't have any method read/writeBoolean . What is the best way to handle this? Here's how I'd do it... writeToParcel: dest.writeByte((byte) (myBoolean ? 1 : 0)); //if myBoolean == true, byte == 1 readFromParcel: myBoolean = in.readByte() != 0; //myBoolean == true if byte != 0 You could also make use of the writeValue method. In my opinion that's the

Pass 2D array to another Activity

£可爱£侵袭症+ 提交于 2019-11-27 05:27:38
how do i pass 2 denominational array object as a parameter to another activity how to get two dimensional array string value in another activity String [][]str; Intent l = new Intent(context,AgAppMenu.class); l.putExtra("msg",str); l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(l); another Activity class String[][] xmlRespone2; xmlRespone2 = getIntent().getExtras().getString("msg"); You can use putSerializable. Arrays are serializable. To store: bundle.putSerializable("list", selected_list); // Here bundle is Bundle object. To access: String[][] passedString_list = (String[][

Parcel Unmarshalling unknown type code

三世轮回 提交于 2019-11-27 04:25:33
问题 We are getting this error in the Crash reports logged by play store. Cant replicate this in all our testing. Does anyone else have the same problem or solution ? Thing is, we dont even know what to do to replicate this bug. All Parcelable objects have CREATOR, writeToParcel() and contructor defined. All Lists and complex types are initialised and null checked. java.lang.RuntimeException: Unable to start activity ComponentInfo{au.com.company/au.com.company.DetailsActivity}: java.lang

How to fix Unmarshalling unknown type code XXX at offset YYY in Android?

假装没事ソ 提交于 2019-11-27 04:24:58
问题 I'm having app crash on resume because of Unmarshalling exception. I've checked all the Serializables have constructor with no parameters and even checked all the serializables using ObjectStream (save to file and load from file). How can i understand actual class type for parcelable offset that cause exception: Parcel android.os.Parcel@42209460: Unmarshalling unknown type code 2131165303 at offset 3748 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2080) at android