parcelable

Why is it possible to write a boolean array to a parcel but not a boolean?

痞子三分冷 提交于 2019-11-30 00:20:34
问题 In the documentation for the Parcel it states a method exists public final void writeBooleanArray (boolean[] val) But there is no method for writeBoolean(boolean val) There also exists: public final void writeLong (long val) public final void writeLongArray (long[] val) So a similar pattern is available for other primitive types. Can some one explain why this is? 回答1: There is an open bug report on it: http://code.google.com/p/android/issues/detail?id=5973 Evidently others agree with your

Android Parcelable - read/write data to Parcel using generic data type

末鹿安然 提交于 2019-11-29 18:12:36
How can i implement to write my Set < ArrayList < ? > > to my Parcel using generic data type ? Here is my code.. dest.writeList(getArrTRA()); dest.writeList(getArrTSAC()); dest.write???(getArrListSet()); //how can i write my Set<ArrayList<? public Set<ArrayList<?>> getArrListSet() { return arrSetOfPaymentMode; } public class ImageContainer implements Serializable, Parcelable { /** * */ private static final long serialVersionUID = 1L; public ImageContainer() { // TODO Auto-generated constructor stub } public ImageContainer(Parcel in) { // TODO Auto-generated constructor stub readFromParcel(in);

How To: Parcel a bitmap in Android

百般思念 提交于 2019-11-29 17:21:47
问题 I have a serialized class which I want to add a bitmap to, but Bitmap doesn't support serialize. Instead I thought I'd use a parcel instead, but can't get it to work. Here's some test code using local variables: Parcel parcel; Bitmap sourceBitmap; Bitmap destinationBitmap; parcel = Parcel.obtain(); sourceBitmap = Bitmap.createBitmap(200, 400, Config.ARGB_8888); sourceBitmap.writeToParcel(parcel, 0); destinationBitmap = Bitmap.CREATOR.createFromParcel(parcel); I get the following error on the

Usage of parceler (@Parcel) with Realm.io (Android)

谁都会走 提交于 2019-11-29 15:25:36
问题 I have the following code which produces the error: Error:Parceler: Unable to find read/write generator for type io.realm.Realm for io.realm.RealmObject.realm It was working all fine without extends RealmObject , however I want to use Realm to put to database easily. Is there a way to exlcude the RealmObject fields and just use the basic pojo fields for @Parcel? @Parcel public class Feed extends RealmObject{ int id; public String text; public String time_created; String time_modified; int

Problem in implementing Parcelable containing other Parcelable

有些话、适合烂在心里 提交于 2019-11-29 15:07:09
问题 I'm implementing Parcelable class that has another Parcelable insde. In OuterParcelable class: @Override public void writeToParcel(Parcel dest, int flags) { Bundle tmp = new Bundle(); tmp.putParcelable("innerParcelable", mParcelable); dest.writeBundle(tmp); and then: public OuterParcelable(Parcel parcel) { super(); Bundle b = parcel.readBundle(); mParcelable = b.getParcelable("innerParcelable"); and: public OuterParcelable createFromParcel(Parcel in) { return new OuterParcelable(in); } When I

Android Parcelable bad array lengths

醉酒当歌 提交于 2019-11-29 13:58:54
Parcelables. Why can't they be more easy? I'm trying to write an application which sends an ArrayList as a parcelable. When I try to get the Intent in the second Activity, I'll get the error: 12-29 21:36:08.158: W/System.err(20117): java.lang.RuntimeException: bad array lengths 12-29 21:36:08.158: W/System.err(20117): at android.os.Parcel.readStringArray(Parcel.java:967) 12-29 21:36:08.158: W/System.err(20117): at net.sutomaji.sv.helperclasses.NewsItem.<init>(NewsItem.java:102) 12-29 21:36:08.158: W/System.err(20117): at net.sutomaji.sv.helperclasses.NewsItem$1.createFromParcel(NewsItem.java

readBooleanArray throws RuntimeException(“bad array lengths”)

余生长醉 提交于 2019-11-29 12:52:16
I knew that parcelable are hide something secret, but didn't thought that i need to know them, unitl now. Here is the code i had before: ... parcel.writeBooleanArray(new boolean[]{booleanValue1, booleanValue2, booleanValue3}); .... boolean[] booleans = new boolean[3]; in.readBooleanArray(booleans); ... Somehow it stops working on many devices except my, so i can't reproduce it. Then i decided to change it to: ... parcel.writeBooleanArray(new boolean[]{booleanValue1}); parcel.writeBooleanArray(new boolean[]{booleanValue2}); parcel.writeBooleanArray(new boolean[]{booleanValue3}); ... boolean[]

Android Kotlin create class implement Parcelable give an error in 'override' of writeToParcel method

有些话、适合烂在心里 提交于 2019-11-29 12:45:04
问题 To use Parcelable, I had followed this release of Kotlin 1.1.4 : https://blog.jetbrains.com/kotlin/2017/08/kotlin-1-1-4-is-out/ Add this line in project androidExtensions { experimental = true } Then define a class : @Parcelize class User(val firstName: String, val lastName: String) : Parcelable The writeToParcel() and createFromParcel() methods are created automatically override fun writeToParcel(parcel: Parcel, flags: Int) { ... } but still have an error in 'override' keyword with message

How can I use AIDL remote service to deal with defferent clients' concurrent requests?

╄→гoц情女王★ 提交于 2019-11-29 11:23:12
I'm writting a plug-in which defines a remote Service and provides a AIDL interface for 3rd party developers. How can I use this remote service to deal with defferent clients' concurrent requests? It is that service apk's activitys can keep status for each client, when they switched between each other, how to do it? This can be achieved using HandlerThread with Looper which maintains and service all the request no matter received from 100 applications. For this AIDL callback interface is also needs to be added as request will be furnished through these callbacks. SERVER APP IAidlService.aidl

Android BadParcelableException only with signed apk

女生的网名这么多〃 提交于 2019-11-29 10:58:18
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 exception happen only with my signed apk? In my proguard config file I did have to use dontwarn android