parcelable

Bad magic number for Bundle in Android

白昼怎懂夜的黑 提交于 2019-11-29 09:24:30
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 implements Parcelable { public static final Creator<Questions> CREATOR = new Creator<Questions>() {

Abstract class as parcelable

橙三吉。 提交于 2019-11-29 09:14:58
Basicly I have the following structure in my app: It would be straightforward to implement such a structure without the abstract class ProjectItem , but in this case I don't know how to implement this. The abstract class ProjectItem needs a CREATOR as it should be parcelable. (like in.readTypedList(mProjectItems, ProjectItem.CREATOR); within the constructor Project(Parcel in)) But in fact, the CREATOR can only be implemented in its derived classes for logical reasons. So, how to implement this structure in order to keep the class Project parcelable?? Edit This is what one of the constructors

Android Store a Parcelable Object in SQLite

不问归期 提交于 2019-11-29 07:40:05
问题 I need to store an object content in Sqlite. I was wondering which was the best way to do it with a serialization of the object or with Parcelable. Is it possible to store it as Parcelable? How can I do it? 回答1: You are welcome to convert your object into some sort of persistable data structure (XML, JSON, Serializable ) and stuff it in some database column. Bear in mind that you will still need to deal with compatibility issues (e.g., Version 2 of your app changes a class, which now needs to

Class not found when Unmarshalling Android Intent Parcelable

强颜欢笑 提交于 2019-11-29 05:37:13
I have a ArrayList that I am passing between activities . In this ArrayList are objects made from a class that has four variables in it. One of those variables is another ArrayList<object> that is from another class . I have implemented Parcelable on both and am pretty sure I have completed the parcelable methods properly. Here are the errors: Errors: 03-18 02:37:27.063: D/dalvikvm(3249): GC_FOR_ALLOC freed 82K, 6% free 3020K/3180K, paused 1ms, total 3ms 03-18 02:37:27.093: I/dalvikvm-heap(3249): Grow heap (frag case) to 3.626MB for 635808-byte allocation 03-18 02:37:27.103: D/dalvikvm(3249):

ClassNotFoundException when unmarshalling: android.support.v4.view.ViewPager$SavedState

喜你入骨 提交于 2019-11-29 05:25:28
I am seeing the following error in my Android crash reports: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v4.view.ViewPager$SavedState at android.os.Parcel.readParcelable(Parcel.java:1971) at android.os.Parcel.readValue(Parcel.java:1859) at android.os.Parcel.readSparseArrayInternal(Parcel.java:2128) at android.os.Parcel.readSparseArray(Parcel.java:1581) at android.os.Parcel.readValue(Parcel.java:1916) at android.os.Parcel.readMapInternal(Parcel.java:2099) at android.os.Bundle.unparcel(Bundle.java:223) at android.os.Bundle

How to use Parcelable in fragment for getting data?

六月ゝ 毕业季﹏ 提交于 2019-11-29 03:55:18
I can use Parcelable in Activity but I don't know how to use it in Fragment. I have a ListFragment in FragmentGet to display all rows database in ListView, I want to get details of ListView in another Fragment when it's clicked, I use Parcelable to passing data between Fragments. This is my Test.java: import android.os.Parcel; import android.os.Parcelable; public class Test implements Parcelable { private int studentNumber; private String studentName; private String studentFamily; public int getStudentNumber() { return studentNumber; } public void setStudentNumber(int studentNumber) { this

Android, How to use readTypedList method correctly in a Parcelable class?

烈酒焚心 提交于 2019-11-28 18:38:00
I have two Activities, in the first one, I instanciate an ArrayList of Object myObject. In the second activity, i need to get this Arraylist. I've found a tutorial : http://prasanta-paul.blogspot.com/2010/06/android-parcelable-example.html I have implemented my class liked it's explain. public class Chapitre implements Parcelable{ private int numero; private String titre; private String description; private int nbVideo; private ArrayList<Video> listeVideo; public Chapitre(int numero, String titre, String description, ArrayList<Video> listeVideo) { this.numero = numero; this.titre = titre; this

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

混江龙づ霸主 提交于 2019-11-28 17:33:01
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 state when a user e.g. presses the HOME-screen button. After some searches I realised that in order to make

Is there a convenient way to create Parcelable data classes in Android with Kotlin?

≯℡__Kan透↙ 提交于 2019-11-28 15:50:59
I'm currently using the excellent AutoParcel in my Java project, which facilitates the creation of Parcelable classes. Now, Kotlin, which I consider for my next project, has this concept of data classes, that automatically generate the equals, hashCode and toString methods. Is there a convenient way to make a Kotlin data class Parcelable in a convenient way (without implementing the methods manually)? Dhaval Jivani Kotlin 1.1.4 is out Android Extensions plugin now includes an automatic Parcelable implementation generator. Declare the serialized properties in a primary constructor and add a

Android 跨进程通信基础

妖精的绣舞 提交于 2019-11-28 15:21:47
Android跨进程通信基础——Binder, BinderProxy, parcel, parcelable, Stub, Stub.Proxy (该文章最早于2013年6月7日发表于有道云笔记 进入阅读 ) 百度、google 过很多文章,都没能找到能够从 API 使用者角度简单描述 Binder,BinderProxy,Parcel,Parcelable,Stub,Stub.Proxy 之间关系的文章,要么高深莫测,要么混乱不清。最终决定还是自己动手,看源码,看文档,现总结如下: Binder,BinderProxy 形成了进程间通信的基础,相当于公路桥梁; Parcel 在 IBinder 基础上传输数据,相当于运输工具; Parcelable 基本数据类型和实现了 Parcelable 接口的复合数据类型才可被 Parcel 传输,相当于摆放整齐、安检合格的货物; Stub,Stub.Proxy 实现跨进程调用的接口,相当于收发货方。 注:Binder,BinderProxy 都实现了 IBinder 接口 下面以 Activity 与 Service 通信为例来分析其运行机制。 示例目的:通过跨进程调用方式在 Activity 进程端调用 Service 进程端的方法。这些方法由接口 RemoteSSO 定义。这里假设两者是运行在不同进程的(也可以运行在相同进程