parcelable

Put Object as intent for next activity

北城以北 提交于 2019-12-22 03:52:59
问题 Is it possible to to put an object of type Object into an intent as a Extra? I have a variable of type object and won't know until it is assigned a value as to what the object datatype is. Maybe something to do with serialization or as a bundle i'm not sure? And then in the next activity how do I then get this value in order to store it in an ArrayList<Object> ? 回答1: Bundle by way of Intent#putExtra does not have any function to add an Object . You can only pass in a Parcelable or a

Android Parcelable Problem with array

你。 提交于 2019-12-21 20:33:37
问题 Hi everybody i have build a class that implements Parcelable but one of the arraylist attributes i have define gets empty when i read the class. Here is the code package roblestech.laCartelera; import java.util.ArrayList; import android.os.Parcel; import android.os.Parcelable; public class ProgramacionPelicula implements Parcelable { public ProgramacionPelicula() { } public ProgramacionPelicula(Pelicula pelicula) { _pelicula = pelicula; } public ProgramacionPelicula(Cine cine) { _cine = cine;

How to send an ArrayList of custom objects in a Bundle

大憨熊 提交于 2019-12-21 06:06:22
问题 I have an application that uses a service to create an ArrayList of custom objects (MyObject) every x seconds. I then want my Activity to obtain this ArrayList. I'm currently planning on having the Service send a message to the Activity's handler every time it finishes the query for the data. I want the message to the Handler to contain the ArrayList of MyObjects. When building the method in the Activity to get this ArrayList out of the message, I noticed that I couldn't. If I tried msg

How to parcel List<Int> with kotlin

半世苍凉 提交于 2019-12-20 02:34:43
问题 I want to pass a data class (that contains list of int as a property) to other activity through Bundle and therefore i need to add Parcelable implementation to my data class. any idea about how to parcel this property? data class Test(val id: Long, val files: List<Int>?) : Parcelable { constructor(parcel: Parcel) : this( parcel.readLong(), TODO("files")) override fun writeToParcel(parcel: Parcel, flags: Int) { parcel.writeLong(id) } override fun describeContents(): Int { return 0 } companion

Save parcelable class into file

浪尽此生 提交于 2019-12-19 10:18:22
问题 I was using a serializable class for I save the xml parser result, but when I read that It is very slow in Android, I changed to parcelable class. Now, I want to save the content parcelable class into file. How can I do it? Thanks. Regards. 回答1: According to Parcel API reference Parcel is not a general-purpose serialization mechanism. This class (and the corresponding Parcelable API for placing arbitrary objects into a Parcel) is designed as a high-performance IPC transport. As such, it is

How to permanently store parcelable custom object? [duplicate]

↘锁芯ラ 提交于 2019-12-19 06:18:59
问题 This question already has answers here : Save Bundle to SharedPreferences [duplicate] (3 answers) Closed 6 years ago . I want to store a custom object (let's call it MyObject) permanently so that if it is deleted from memory, I can reload it in my Activity / Fragment onResume() method when the app starts again. How can I do that? SharedPreferences doesn't seem to have a method for storing parcelable objects. 回答1: If you need to store it in SharedPreferences, you can parse your object to a

How to Pass Drawable using Parcelable

微笑、不失礼 提交于 2019-12-18 18:56:54
问题 I have a class where i have an Drawable as an member. This class i am using for sending data across activities as an Parcelable extra. For that i have extended the parceble, and implemented the required functions. I am able to send the basic data types using read/write int/string. But i am facing problem while marshaling the Drawable object. For that i tried to convert the Drawable to byte array , but i am getting class cast Exceptions. I am using following code to covert my Drawable to Byte

YouTube Android Player API throws “BadParcelableException ClassNotFoundException when unmarshalling: asc” with new YouTube version

≡放荡痞女 提交于 2019-12-18 13:18:08
问题 Filing bug to YouTube Android Player API Library engineers: see android-youtube-api tag Over the course of the past week and a half, I've noticed this weird BadParcelableException steadily increasing in our app and have nailed it down to YouTube's new release on android. This crash will occur if your app is playing a youtube video, bringing your app to background, force stopping the Youtube app, and resuming your app again. Crash reproducible on Youtube version 12.19.56. Also tested on an

Transferring ByteArray through Parcel returns NullPointerException

岁酱吖の 提交于 2019-12-18 12:13:14
问题 import android.os.Parcel; import android.os.Parcelable; public class MClass implements Parcelable { private byte[] _byte; public MClass() { } public MClass(Parcel in) { readFromParcel(in); } public byte[] get_byte() { return _byte; } public void set_byte(byte[] _byte) { this._byte = _byte; } public int describeContents() { return 0; } public void writeToParcel(Parcel dest, int flags) { dest.writeByteArray(_byte); } public void readFromParcel(Parcel in) { in.readByteArray(_byte); //LOE - Line

Android BadParcelableException only with signed apk

这一生的挚爱 提交于 2019-12-18 06:46:42
问题 When I run my project from debug everything works fine. However when I run it with the signed apk I generated from Android Studio (using proguard), I get the following errors when using getParcelable: java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage.android/mypackage.mobile.android.activities.searchActivity}: android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object called CREATOR on class mypackage.android.a.d.a Why does this