parcelable

Saving Parcelable data

社会主义新天地 提交于 2019-12-24 08:37:58
问题 I have a class which implements Parcelable, and could not implement Serializable because it contains some basic Android classes that I can not modify. Some of the objects in this class are for example Location and PendingIntent (which are all conveniently Parcelable). My problem is saving this information between the instances of my main Activity. Currently, I'm holding a static reference to this class, which works well. But I assume that when I re-install the app, and probably when updates

Is GoogleMap inherently Parcelable?

喜你入骨 提交于 2019-12-24 03:05:21
问题 I am very new to java and android. I am stuck with a basic problem. In this given fragment , I can add GoogleMap object as parcelable without any extra pracelable class as: public class SecondFragment extends Fragment implements OnMapReadyCallback { public GoogleMap mMap; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { mLastKnownLocation = savedInstanceState.getParcelable(KEY_LOCATION); mCameraPosition =

Unmarshalling unknown type code exception while resuming

白昼怎懂夜的黑 提交于 2019-12-23 20:24:26
问题 I have an application in which i got tablayout with two fragments, the app works perfectly fine but when i close app using menu button and use other apps for a while and when i resume my app it crashes with the following exception FATAL EXCEPTION: main Process: com.example.com, PID: 5674 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.com/com.example.ui.activity.MainActivity}: java.lang.RuntimeException: Parcel android.os.Parcel@9095b3a: Unmarshalling unknown

Persisting a Parcelable object in Android

扶醉桌前 提交于 2019-12-23 13:07:14
问题 I have a class in my Android app that I've made Parcelable so that it can be passed between Activities. I would like to be able to save this object to the filesystem. It seems that since I've already implemented Parcelable, it would make sense to pipe the output of this to the filesystem and read it back later. Is there a correct way to do this? Or must I implement both Parcelable and Serialiazble if I want to both pass the object between Activities and also save it to the filesystem? 回答1:

Passing ArreyList between Fragments with Parcelable

你说的曾经没有我的故事 提交于 2019-12-23 04:38:09
问题 After consuming a json with Retrofit and using unsynchronous callback I can't pass An ArrayList from The MainActivity to a fragment . Code from MainActivity: lFragmentManager = getFragmentManager(); lFragment = lFragmentManager.findFragmentById(R.id.frame_container); lFragment = new Fragment_Categories(); Bundle bundle = new Bundle(); bundle.putParcelableArrayList("list_categories", Categories_.getCategories()); //for(int a = 0 ; a < Categories_.getCategories().size(); a++) // Log.d("billy"

Crash when reading nested Parcelable

99封情书 提交于 2019-12-22 23:00:12
问题 I have a class that extends Parcelable. It has a member variable which is an ArrayList of another class which also extends Parcelable. I pass the MyClass1 object in an Intent back to an Activity and read it in. When the constructor reaches in.readTypedList, the app crashes with the following error: 04-11 14:19:11.223: E/AndroidRuntime(502): Uncaught handler: thread main exiting due to uncaught exception 04-11 14:19:11.234: E/AndroidRuntime(502): java.lang.RuntimeException: Failure delivering

ArrayList<ArrayList<String>> in Parcelable object kotlin

隐身守侯 提交于 2019-12-22 22:06:07
问题 Array of arrays of strings needs to be parcelized. The object is like so data class Foo ( @SerializedName("bar") val bar: ArrayList<ArrayList<String>>, ) It doesn't exactly need to be ArrayList. Array can also used. data class Foo ( @SerializedName("bar") val bar: Array<Array<String>>, ) Whichever easier is ok to map this json data { "bar": [ ["a", "b"], ["a1", "b2", "c2"], ["a3", "b34", "c432"] ] } Using kotlin experimental Parcelize crashes the app when it's compiled with progaurd How is it

onSaveInstanceState() vs. onRetainCustomNonConfigurationInstance()

杀马特。学长 韩版系。学妹 提交于 2019-12-22 09:59:17
问题 I am using ActionBarSherlock, along with several MenuItem s that I dynamically manage, depending on program state. Specifically, I save the MenuItem s into instance variables in the Activity 's onCreateOptionsMenu() method, and then can show and/or hide them as needed later in the Activity . However, I found that the MenuItem variables can be lost on configuration changes, such as device rotation. So I also put them into a Parcel and pass them to onSaveInstanceState() for restoral through the

Parcelable inheritance: abstract class - Which CREATOR?

蹲街弑〆低调 提交于 2019-12-22 04:38:23
问题 I have an abstract class A which implements Parcelable. I have a class B and a class C who both extend A . How can I make them parcelable? Of cause I could chain it and provide a CREATOR both in A and B like suggested in many posts. But since I have other Objects who store the A-B-C classes and implement Parcelable themselfes, that approach seems not to be working because when I want to pass an ArrayList of A I would have to use the CREATOR in the typed list by ArrayList<A> elements = new

Why use parcelable when you can perform the same task using static variables?

喜夏-厌秋 提交于 2019-12-22 04:15:30
问题 i am new in android and java ... i am reading from couples of day about android parceling tutorial for transfer data or variables values from one activity to other or one class to other ... but i am not so understood about that. can u tell me that is it necessary to use Parcelable for this purpose because same task can also be perform using static key word for variables as string,int or array type then why parcelable pls explain in detail .. thanks for explanation in advance please provide