我正在開發與SearchView的應用程序。應用程序與SearchView崩潰恢復
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.github.ndczz.searchviewtest, PID: 20393
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.github.ndczz.searchviewtest/com.github.ndczz.searchviewtest.MainActivity}: java.lang.RuntimeException: Parcel [email protected]: Unmarshalling unknown type code 3801188 at offset 1980
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.RuntimeException: Parcel [email protected]: Unmarshalling unknown type code 3801188 at offset 1980
at android.os.Parcel.readValue(Parcel.java:2319)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2592)
at android.os.BaseBundle.unparcel(BaseBundle.java:221)
at android.os.Bundle.getSparseParcelableArray(Bundle.java:856)
at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2033)
at android.app.Activity.onRestoreInstanceState(Activity.java:1004)
at android.app.Activity.performRestoreInstanceState(Activity.java:959)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1163)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
菜單/ search.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/search"
android:icon="@android:drawable/ic_search_category_default"
android:title="Search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always|collapseActionView" />
</menu>
:
當我打開搜索視圖中,按「家」,並以「不保留活動」選項啓用還原應用程序,它具有異常崩潰
MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search, menu);
return true;
}
}