Reputation: 21
I am working with the library Searchable Spinner, but if I press the android home button or multitasking button when I have open the spinner, the app crashes and print on screen: "Unfortunately, Appname has stoppeed."
My fragmentactivity:
public class buscadorFragment extends Fragment implements View.OnClickListener {
public Button BotonRecargar;
public IndeterminateRoadRunner UCargando;
public TextView TextoPrueba;
public TextView TextoError;
private OnFragmentInteractionListener mListener;
public SearchableSpinner SpCateg;
public SearchableSpinner SpUbic;
String[] CategoriasArray = {"Categorias"};
String[] UbicacionesArray ={"Ubicaciones"};
ArrayAdapter<String> CatspinnerAdapter;
ArrayAdapter<String> UbicspinnerAdapter;
public buscadorFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_buscador, container, false);
CatspinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, CategoriasArray);
CatspinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
SpCateg.setAdapter(CatspinnerAdapter);
CatspinnerAdapter.notifyDataSetChanged();
UbicspinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, UbicacionesArray);
UbicspinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
SpUbic.setAdapter(UbicspinnerAdapter);
UbicspinnerAdapter.notifyDataSetChanged();
SpCateg.setTitle("Categoría");
SpCateg.setPositiveButton("Cancelar");
SpUbic.setTitle("Ubicación");
SpUbic.setPositiveButton("Cancelar");
return view;
}
My fragment layout:
only add
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2">
<com.toptoche.searchablespinnerlibrary.SearchableSpinner
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:id="@+id/Category_Spinner" />
<com.toptoche.searchablespinnerlibrary.SearchableSpinner
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="1"
android:id="@+id/Ubication_Spinner" />
</LinearLayout>
There is the logcat:
08-31 20:09:21.656 18172-18172/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.kreativer.upy, PID: 18172
java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.toptoche.searchablespinnerlibrary.SearchableSpinner)
at android.os.Parcel.writeSerializable(Parcel.java:1323)
at android.os.Parcel.writeValue(Parcel.java:1271)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618)
at android.os.Bundle.writeToParcel(Bundle.java:1692)
at android.os.Parcel.writeBundle(Parcel.java:643)
at android.app.FragmentState.writeToParcel(Fragment.java:133)
at android.os.Parcel.writeTypedArray(Parcel.java:1140)
at android.app.FragmentManagerState.writeToParcel(FragmentManager.java:373)
at android.os.Parcel.writeParcelable(Parcel.java:1292)
at android.os.Parcel.writeValue(Parcel.java:1211)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618)
at android.os.Bundle.writeToParcel(Bundle.java:1692)
at android.os.Parcel.writeBundle(Parcel.java:643)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2643)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3252)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5426)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.io.NotSerializableException: android.widget.ArrayAdapter
at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1366)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1673)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1519)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1483)
at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:981)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:368)
at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1076)
at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1406)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1673)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1519)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1483)
at android.os.Parcel.writeSerializable(Parcel.java:1318)
at android.os.Parcel.writeValue(Parcel.java:1271)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618)
at android.os.Bundle.writeToParcel(Bundle.java:1692)
at android.os.Parcel.writeBundle(Parcel.java:643)
at android.app.FragmentState.writeToParcel(Fragment.java:133)
at android.os.Parcel.writeTypedArray(Parcel.java:1140)
at android.app.FragmentManagerState.writeToParcel(FragmentManager.java:373)
at android.os.Parcel.writeParcelable(Parcel.java:1292)
at android.os.Parcel.writeValue(Parcel.java:1211)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:618)
at android.os.Bundle.writeToParcel(Bundle.java:1692)
at android.os.Parcel.writeBundle(Parcel.java:643)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2643)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3252)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5426)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Crashes only when the spinner is opened, otherwise the app keep running. I am newbie and want to learn, so thanks in advance.
Upvotes: 2
Views: 1051
Reputation: 11
Add this library in app's gradle file, inside dependencies:
implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
Upvotes: 0
Reputation: 958
Looks like it is an issue with the library as other users reported the same issue on Github. For resolving the issue, you can dismiss the searchableListDialog in onPause() method.
So write the following code in SearchableListDialog.java
@Override
public void onPause()
{
super.onPause();
dismiss();
}
Upvotes: 1