parcelable

Key _id expected Parcelable but value was java.lang.Long. while passing Parceable object between Activity

北慕城南 提交于 2019-12-24 18:08:04
问题 I want to pass an object of my custom class to another activity. I came to know that Parceable is way and WAY faster than Serializable. But doing so i get the exception Key _id expected Parceable but value was java.lang.Long. The default value <null> was returned. I don't know what i am doing wrong with it. I followed these tutorials: Passing custom objects between android activities And the one very popular StackOverFlow answer The code of my object that implements Parcelable is as follows:

android - java - pass values through intents, bundles or Parcelables?

浪尽此生 提交于 2019-12-24 17:53:13
问题 Context: Android I read a lot of examples on the net for passing datas between activities. What I learned : Pass primitive datas through Intents (intent.putExtra(key,value)) Bundle the primitive datas and put it in an intent.putExtra(key,bundle object) Parcelables -> for complex objects and primitives. Before you say it, yes, I certainly missed something. Question: Well, it seems that there are multiple ways to achieve the same goal. If I want to pass a custom object, a Parcelable is my man.

Android - Parcel: unable to marshal value

☆樱花仙子☆ 提交于 2019-12-24 16:16:40
问题 I'm trying to pass data through activities with Parcelable. This is my code : public class Player implements Parcelable { public static final Parcelable.Creator<Player> CREATOR = new Parcelable.Creator<Player>() { public Player createFromParcel(Parcel in) { return new Player(in); } public Player[] newArray(int size) { return new Player[size]; } }; private String name; private List<Card> listCards; public Player(String namePlayer) { name = namePlayer; listCards = new ArrayList<>(); } private

How to pass json object data using Gson?

雨燕双飞 提交于 2019-12-24 15:19:55
问题 i know there is lots of solution available but none of them help me i am parsing json data data using Gson, and i want to parse this data to another activity as well but i am getting null pointer exception on that. RequestQueue requestQueue = Volley.newRequestQueue(mContext); JsonObjectRequest jsOnbjRequest = new JsonObjectRequest(Request.Method.POST, Constants.MyProfile, userProfile, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { // Toast

How to use Parcelable on non-primitive types?

被刻印的时光 ゝ 提交于 2019-12-24 11:15:09
问题 I have a class TableMetaAttrs: public class TableMetaAttrs implements Parcelable { private Integer id; private String name; private String value; private Tables table; ... How do i implement Parcelable on table field? Class Tables also implements Parcelable. 回答1: You have to make the Tables class implements Parcelable as well. That way whenever TableMetaAttrs is parcelling or re-building itself, it can call putParcelable and getParcelable for the table field. edit: I'm assuming Tables is a

Error with Parcelable object: Unmarshalling unknown type code *** at offset ***

偶尔善良 提交于 2019-12-24 10:40:02
问题 I'm trying to finish this project for school and I keep getting this error in the 'read' portion of my Parcelable code. This has eaten up many hours of my day and I've read countless StackOverflow pages with similar problems and none of those solutions worked for me. Here are things I've read about and doesn't seem to be the issue: Proguard (since I'm not using) Android Studio up to date Mismatched 'read' and 'write' types The order of the parameters of the object in 'read and 'write'

Share Parcelable object from Fragment to Activity

扶醉桌前 提交于 2019-12-24 10:39:54
问题 Hello i try to pass object from Fragment to Activity like next: Bundle bundle1 = new Bundle(); bundle1.putParcelable("company", companies.get(i)); Intent intent = new Intent(getActivity(), CompanyInfoActivity.class); intent.putExtras(bundle1); getActivity().startActivity(intent); And in Activity i make next: Intent intent = getIntent(); Bundle bundle = intent.getExtras(); company = bundle.getParcelable("company"); And i Try: Intent intent = new Intent(getActivity(), CompanyInfoActivity.class)

Android Studio: Pass parcelable data to call service (Phone Call App)

泄露秘密 提交于 2019-12-24 10:24:11
问题 I am using this app as a framework and trying to pass an object to my own UI Phone Call . But when I try to put my object into myAdapter : Call.putExtra("itemObject", items.get(position)); I get a BadParcelableException error: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.server.telecom/com.android.server.telecom.components.UserCallActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.example.aliton.customphonecall

Get generics class loader for parsing nested Parcelable generic field

自作多情 提交于 2019-12-24 09:48:56
问题 I have a wrapper of Parcelable generic type but Parcel constructing fails to compile because T class can not be determined generically class MyItem<T : Parcelable> (val model: T) : Parcelable { constructor(parcel: Parcel) : this(parcel.readParcelable(T::class.java.classLoader)) { } } Is there any solution to this case? 回答1: In order to get the whole picture here is what I ended up with: The use case is one has a Parcelable generic instance let's call it model which should be completed with

Android abstract arraylist parcelable

这一生的挚爱 提交于 2019-12-24 09:14:59
问题 I have an arraylist of abstract objects(animals) and I'm trying to send and restore this array. The problem is that I need to give a creator when rebuilding the array, at this moment I'm passing a string that I check in the Animal creator and check what kind of animal I need to create. I don't thing this is the most effective, so is there a better way to create a parcelable abstract array? Here is a little demo project that describes the problem. https://github.com/Evertvandenbruel/parcelable