I go к активности из двух фрагментов, и я передаю статистику через намерение, первое намерение - данные
Intent intent = new Intent(getContext(), AllAlbumImgActivity.class);
photoGrapherSavedPhoto.albumName=getResources().getString(R.string.photos);
intent.putExtra(SELECTED_IMG_ID, photoGrapherSavedPhoto.id);
intent.putExtra(LIST_NAME, getActivity().getResources().getString(R.string.photos));
intent.putExtra(LIST_TYPE, CURRENT_PHOTOGRAPHER_PHOTOS_LIST);
intent.putExtra(CURRENT_PAGE, nextPageUrl);
intent.putParcelableArrayListExtra(ALL_ALBUM_IMAGES, (ArrayList<? extends Parcelable>) photoGrapherPhotoList);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(intent, ALBUM_LIST_REQUEST_CODE);
, и оно работало нормально
второе намерение
Intent intent = new Intent(getContext(), AllAlbumImgActivity.class);
photoGrapherSavedPhoto.albumName="Saved";
intent.putExtra(SELECTED_IMG_ID, photoGrapherSavedPhoto.id);
intent.putExtra(LIST_NAME, getActivity().getResources().getString(R.string.saved));
intent.putExtra(LIST_TYPE, CURRENT_PHOTOGRAPHER_SAVED_LIST);
intent.putExtra(CURRENT_PAGE, nextPageUrl);
intent.putParcelableArrayListExtra(ALL_ALBUM_IMAGES, (ArrayList<? extends Parcelable>) photoGrapherSavedPhotoList);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(intent, ALBUM_LIST_REQUEST_CODE);
но он не работает нормально с данными второго намерения
вот как я получаю данные
if (intent.getSerializableExtra(LIST_TYPE) != null)
photosListType = (Constants.PhotosListType) intent.getSerializableExtra(LIST_TYPE);
if (intent.getStringExtra(LIST_NAME) != null)
topBarTitle.setText(intent.getStringExtra(LIST_NAME));
if (photosListType == CURRENT_PHOTOGRAPHER_PHOTOS_LIST || photosListType == CURRENT_PHOTOGRAPHER_SAVED_LIST) {
nextPageUrl = intent.getStringExtra(CURRENT_PAGE);
}
if (intent.getParcelableArrayListExtra(ALL_ALBUM_IMAGES) != null) {
this.albumImgList = intent.getParcelableArrayListExtra(ALL_ALBUM_IMAGES);
int selectedPosition = intent.getIntExtra(SELECTED_IMG_ID, 0);
for (int i = 0; i < albumImgList.size(); i++) {
if (albumImgList.get(i).id == selectedPosition) {
// Objects.requireNonNull(allAlbumImgRv.getLayoutManager()).smoothScrollToPosition(allAlbumImgRv, null, i);
scrolledPosition = i;
break;
}
}
}
, но когда я передаю второе намерение, он показывает эту ошибку
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.softmills.phlog, PID: 14899
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softmills.phlog/com.example.softmills.phlog.ui.album.view.AllAlbumImgActivity}: java.lang.RuntimeException: Parcel android.os.Parcel@b21b847: Unmarshalling unknown type code 7274595 at offset 1100
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@b21b847: Unmarshalling unknown type code 7274595 at offset 1100
at android.os.Parcel.readValue(Parcel.java:2747)
at android.os.Parcel.readListInternal(Parcel.java:3098)
at android.os.Parcel.readArrayList(Parcel.java:2319)
at android.os.Parcel.readValue(Parcel.java:2689)
at android.os.Parcel.readArrayMapInternal(Parcel.java:3037)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:288)
at android.os.BaseBundle.unparcel(BaseBundle.java:232)
at android.os.BaseBundle.getSerializable(BaseBundle.java:1227)
at android.os.Bundle.getSerializable(Bundle.java:1034)
at android.content.Intent.getSerializableExtra(Intent.java:7516)
at com.example.softmills.phlog.ui.album.view.AllAlbumImgActivity.initView(AllAlbumImgActivity.java:97)
at com.example.softmills.phlog.ui.album.view.AllAlbumImgActivity.onCreate(AllAlbumImgActivity.java:85)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
там я передавал весь альбом как доступный для просмотра и в двух намерениях он имеет один и тот же объект
, но одна работа и одна вызывают странную ошибку, связанную с parcelable !!