Good afternoon, ladies and gentlemen. I am writing an application for android, and I encountered the following problem ... After my application is open, I open other demanding applications: games, browser, etc., then android destroys the active fragment / activity in my application, freeing up so . resources for the system. Then I try to open the application again, but it is overloaded and painted. Error description:
java.lang.RuntimeException: Unable to start activity ComponentInfo {my_app / md530ee4884bf1bb4f3619af03b33af6888.MainActivity}: java.lang.RuntimeException: Parcel android.os.Parcel@7b3d21a: unmarshalling type 21 2140.a. (ActivityThread.java:2426) at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2490) at android.app.ActivityThread.-wrap11 (ActivityThread.java) at android.app.ActivityThread $ H.handleMessage (ActivityThread.java : 1354) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:148) at android.app.ActivityThread.main (ActivityThread.java Zin443) at java .lang.reflect.Method.invoke (Native Method) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:728) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 618) Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@7b3d21a: Unmarshalling unknown type code 21310998 24 at offset 460 at android.os.Parcel.readValue (Parcel.java:2340) at android.os.Parcel.readSparseArrayInternal (Parcel.java:2675) at android.os.Parcel.readSparseArray (Parcel.java:1967) at android.os.Parcel.readValue (Parcel.java:2321) at android.os.Parcel.readArrayMapInternal (Parcel.java:2614) at android.os.BaseBundle.unparcel (BaseBundle.java:221) at android.os.Bundle .getSparseParcelableArray (Bundle.java:856) at android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:997) at android.support.v4.app.FragmentManagerImpl.moveToSerate in an account of it, in the form of a file in support of the file in an account of this, in the form of a file. support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1234) at android.support.v4.app.FragmentManagerImpl.dispatchCreate (FragmentManager.java:2041) at android.support.v4.app.FragmentContraphraphr.appraptane.java:2041) at android.support.v4.app.FragmentContraphraph.apprapt.phrathrapt.vr.apprach.phragonMap.raft.crypt.phragonMmp. java: 163) at android.support.v4.app.FragmentActivity.onCreate (FragmentActivity.java.7331) at android.support.v7.app.AppCompatActivity.onCreate (AppCompatActivity.java:85) at md530ee4884bf1bb4f3619af03b33af6888.MainActivity. : 1130) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2379) ... 9 more
How to make android not destroy fragment / activity? Or maybe some other solution? I am writing in C # Xamarin , but in Java the code is almost identical.
Calling a fragment from the MainActivity :
SupportFragment fragment = new ItemCharacteristicsFragment(); var fragmentManager = SupportFragmentManager.BeginTransaction(); fragmentManager.Replace(Resource.Id.flContent, fragment); fragmentManager.AddToBackStack(null); fragmentManager.CommitAllowingStateLoss();
The fragment itself:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; using SupportFragment = Android.Support.V4.App.Fragment; using ShopMobile; using Android.Text; namespace StozharyApp.Classes { class ItemCharacteristicsFragment : SupportFragment { public ItemElement Item { get; set; } public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your fragment here } public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.Inflate(Resource.Layout.ItemCharacteristics, container, false); TextView txtCharacteristics = view.FindViewById<TextView>(Resource.Id.txtCharacteristics); txtCharacteristics.TextFormatted = Html.FromHtml(Item.Desc); return view; } } }