parcelable

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

浪尽此生 提交于 2019-11-28 13:24:18
问题 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; } 回答1: public class ImageContainer implements Serializable, Parcelable { /** * */ private static final long serialVersionUID = 1L; public ImageContainer() { // TODO Auto-generated

android parcelable referencing another parcelable circular dependence

痴心易碎 提交于 2019-11-28 10:10:50
Rather simple scenario really, but I could not find anything related on Google so here goes: class ContainerClass implements Parcelable { List<ItemClass> _items; (...) public void writeToParcel( Parcel p, int args ) { p.writeList( _items ); (...) } } class ItemClass implements Parcelable { ContainerClass _containerRef; (...) public void writeToParcel( Parcel p, int args ) { p.writeParcelable( _containerRef ); (...) } } This will inevitably loop and overflow the stack. My question: How am I supposed to deal with a situation where I have to pass an object of the above types through to a new

Android Fragments Retaining Data

久未见 提交于 2019-11-28 08:07:48
问题 How does one best retain data within a Fragment as its activity goes through an onCreate/Destroy cycle like from Rotation? In our setup we have potentially large lists loaded from our servers into the fragments custom list adapter and we want to smooth out the UX by not making them reload on rotation. The problem we had with setting the fragment retainInstance=true; is that our adapter has a reference to the context of the original activity and would therefore leak memory. Could we just store

Parcelable protocol requires a Parcelable.Creator object called CREATOR (I do have CREATOR)

让人想犯罪 __ 提交于 2019-11-28 06:51:08
I am trying to pass Parcelable data from one intent to another and this is the error I am getting: 08-31 14:12:22.709: E/AndroidRuntime(9931): FATAL EXCEPTION: main 08-31 14:12:22.709: E/AndroidRuntime(9931): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.matejsoftware.cardscoretracker/com.matejsoftware.cardscoretracker.Igra}: android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object called CREATOR on class com.matejsoftware.cardscoretracker.Novaigra$Player The thing is: I do have Parcelable.Creator object. I'll post the whole

readBooleanArray throws RuntimeException(“bad array lengths”)

廉价感情. 提交于 2019-11-28 06:31:29
问题 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

How to serialize null value when using Parcelable interface

若如初见. 提交于 2019-11-28 06:08:29
regarding my code example down, what shold I do if one Locable's variables is null? In example, now if l.getZoom() returns null, I got NullPointerException. @Override public void writeToParcel(Parcel parcel, int arg1) { parcel.writeInt(count); for(Locable l:locableArr){ parcel.writeInt(l.getOriginId()); parcel.writeInt(l.getLocableType()); parcel.writeInt(l.getZoom()); parcel.writeDouble(l.getLatituda()); parcel.writeDouble(l.getLongituda()); parcel.writeString(l.getTitle()); parcel.writeString(l.getSnipet()); } } Thanks! You can use Parcel.writeValue for marshalling generic object with null

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

Deadly 提交于 2019-11-28 04:53:57
问题 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? 回答1: 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

Arraylist in parcelable object

别等时光非礼了梦想. 提交于 2019-11-28 04:31:02
I have seen many parcelable examples so far, but for some reason I can't get it to work when it gets a bit more complex. I have a Movie object, which implements Parcelable. This book object contains some properties, such as ArrayLists. Running my app results in a NullPointerException when executing the ReadTypedList ! I'm really out of ideas here public class Movie implements Parcelable{ private int id; private List<Review> reviews private List<String> authors; public Movie () { reviews = new ArrayList<Review>(); authors = new ArrayList<String>(); } public Movie (Parcel in) { readFromParcel(in

AIDL unable to find the definition of a Parcelable class

荒凉一梦 提交于 2019-11-28 04:18:00
问题 I have the following project structure. My StockInfo.java is perfectly fine. StockInfo.java (No error) package org.yccheok.jstock.engine; import android.os.Parcel; import android.os.Parcelable; public class StockInfo implements Parcelable { ... ... StockInfo.aidl (No error) package org.yccheok.jstock.engine; parcelable StockInfo; StockInfoObserver.aidl (Error!) package org.yccheok.jstock.engine; interface StockInfoObserver { void update(StockInfo stockInfo); } AutoCompleteApi.aidl (Error!)

Bad magic number for Bundle in Android

房东的猫 提交于 2019-11-28 02:53:31
问题 I'm passing data from one activity to other activity with this code: @Override public void execute(List<Report> reports, Questions question) { Intent replyIntent = new Intent(listener, ReplyActivity.class); replyIntent.putExtra("id", 0L); replyIntent.putExtra("questions", question); listener.openReportOk(question); listener.startActivity(replyIntent); } Listener its a Activity reference for callbacks. Questions is this class: @Table(name = "Questions") public class Questions extends Entity