gpt4 book ai didi

java - Android java.lang.IllegalArgumentException : Duplicate key in ArrayMap: null

转载 作者:行者123 更新时间:2023-12-04 14:07:00 25 4
gpt4 key购买 nike

我收到此错误

Caused by java.lang.IllegalArgumentException: Duplicate key in ArrayMap: null



不在我当前的设备中,但它来自 crashlytics,但我无法在我自己的设备中重新生成此问题尝试了所有可能的方法,但无法在我的设备中出现同样的错误,下面是我的代码,非常感谢答案。
public class QuestionSwipeFragment extends DialogFragment {

private View mRootView;
private int mPosition;
private List<ResourceModel> mResourceList;
private QuestionSwipePagerAdapter mQuestionSwipePagerAdapter;
private ViewPager mPager;

private int mSelectedChapterId;
private int mSelectedSectionId;
private int mSelectedSubSectionId;
private boolean mSelectedFavourite;

private boolean mIsFavourite;
private boolean mIsPagination;

private int mCurrentPage;
private int mTotalPage;

int mResourcePageNo;
int mMarkId;
int mDifficulties;

private int mFragmentType;

private int mFragType;
private PaginationParams mPaginationParams = new PaginationParams();

private static final int RESOURCE_ALL = -1;

private boolean onDestroy = false;

private static final String API_TYPE_PAGINATION = "pagination";

public QuestionSwipeFragment() {
// Required empty public constructor
}

public static DialogFragment newInstance(List<ResourceModel> mResourceList, int id, int fragType, boolean isFavourited, boolean isPaginationRequest,
int chapterId, int sectionId,
int resourcePageNo, int markId,
int difficulties, int currentPage,
int totalPage) {
Bundle bundle = new Bundle();
QuestionSwipeFragment fragment = new QuestionSwipeFragment();

bundle.putParcelableArrayList(Constants.QUESTION_SWIPE_RESOURCE_LIST, (ArrayList<? extends Parcelable>) mResourceList);
bundle.putInt(Constants.QUESTION_SWIPE_RESOURCE_LIST_POSTION, id);
bundle.putInt(Constants.QUESTION_SWIPE_TYPE_FRAGMENT, fragType);

bundle.putBoolean(Constants.QUESTION_SWIPE_ISFAVOURITED, isFavourited);
bundle.putBoolean(Constants.QUESTION_SWIPE_ISPAGINATIONREQUEST, isPaginationRequest);

bundle.putInt(Constants.QUESTION_SWIPE_SELECTED_CHAPTER_ID, chapterId);
bundle.putInt(Constants.QUESTION_SWIPE_SELECTED_SECTION_ID, sectionId);

bundle.putInt(Constants.QUESTION_SWIPE_RESOURCEPAGE_NO, resourcePageNo);
bundle.putInt(Constants.QUESTION_SWIPE_MARKID, markId);
bundle.putInt(Constants.QUESTION_SWIPE_DIFFICULTIES, difficulties);


bundle.putInt(Constants.QUESTION_SWIPE_CURRENTPAGE, currentPage);
bundle.putInt(Constants.QUESTION_SWIPE_TOTALPAGE, totalPage);

fragment.setArguments(bundle);
return fragment;
}

public static DialogFragment newInstance(List<ResourceModel> mResourceList, int position, int fragType,
int selectedChapterId, int selectedSectionId, int selectedSubSectionId, int currentPage, int totalPage) {
Bundle bundle = new Bundle();
QuestionSwipeFragment fragment = new QuestionSwipeFragment();
bundle.putParcelableArrayList(Constants.QUESTION_SWIPE_RESOURCE_LIST, (ArrayList<? extends Parcelable>) mResourceList);
bundle.putInt(Constants.QUESTION_SWIPE_RESOURCE_LIST_POSTION, position);
bundle.putInt(Constants.QUESTION_SWIPE_TYPE_FRAGMENT, fragType);

bundle.putInt(Constants.QUESTION_SWIPE_SELECTED_CHAPTER_ID, selectedChapterId);
bundle.putInt(Constants.QUESTION_SWIPE_SELECTED_SECTION_ID, selectedSectionId);
bundle.putInt(Constants.QUESTION_SWIPE_SELECTED_SUBSECTION_ID, selectedSubSectionId);

bundle.putInt(Constants.QUESTION_SWIPE_CURRENTPAGE, currentPage);
bundle.putInt(Constants.QUESTION_SWIPE_TOTALPAGE, totalPage);

bundle.putInt(Constants.QUESTION_SWIPE_CURRENTFRAGMENT, fragType);

fragment.setArguments(bundle);
return fragment;
}

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handleBundle(getArguments());
setStyle(DialogFragment.STYLE_NORMAL, R.style.MyMaterialTheme);
}

//the below method is causing IllegalArgumentException
private void handleBundle(Bundle bundle) {
if (bundle != null) {
if (bundle.containsKey(Constants.QUESTION_SWIPE_RESOURCE_LIST)) {
mResourceList = bundle.getParcelableArrayList(Constants.QUESTION_SWIPE_RESOURCE_LIST);
mPosition = bundle.getInt(Constants.QUESTION_SWIPE_RESOURCE_LIST_POSTION);
mFragType = bundle.getInt(Constants.QUESTION_SWIPE_TYPE_FRAGMENT);

mSelectedChapterId = bundle.getInt(Constants.QUESTION_SWIPE_SELECTED_CHAPTER_ID);
mSelectedSectionId = bundle.getInt(Constants.QUESTION_SWIPE_SELECTED_SECTION_ID);

mSelectedSubSectionId = bundle.getInt(Constants.QUESTION_SWIPE_SELECTED_SUBSECTION_ID);

mIsFavourite = bundle.getBoolean(Constants.QUESTION_SWIPE_ISFAVOURITED);
mIsPagination = bundle.getBoolean(Constants.QUESTION_SWIPE_ISPAGINATIONREQUEST);

mCurrentPage = bundle.getInt(Constants.QUESTION_SWIPE_CURRENTPAGE);
mTotalPage = bundle.getInt(Constants.QUESTION_SWIPE_TOTALPAGE);

mResourcePageNo = bundle.getInt(Constants.QUESTION_SWIPE_RESOURCEPAGE_NO);
mMarkId = bundle.getInt(Constants.QUESTION_SWIPE_MARKID);
mDifficulties = bundle.getInt(Constants.QUESTION_SWIPE_DIFFICULTIES);

mFragmentType = bundle.getInt(Constants.QUESTION_SWIPE_CURRENTFRAGMENT);
}
}
}

下面是我从适配器开始这个 fragment 的代码
private void setonClickListeners(ResourceQuestionsViewHolder viewHolder, final int position) {
viewHolder.mContainerView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

DialogFragment questionSwipeFragment = QuestionSwipeFragment.newInstance(getExtractResourceInfo(position).getExtractedList(), getExtractResourceInfo(position).getPosition(), Constants.QB_DETAILS_FRAGMENT, isFavourited, isPaginationRequest, chapterId, sectionId, resourcePageNo, markId, difficulties, mCurrentPage, mTotalPage);
questionSwipeFragment.show(((QuestionBankActivity) mContext).getSupportFragmentManager(), "dialog");

}
});
}

private void setonLongClickListener(SubSectionResourceQuestionsViewHolder viewHolder, final int position) {
viewHolder.mContainerView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {

DialogFragment questionBankFragment = QBSubSectionDetailFragment.newInstance(mResourceList, false, position);
questionBankFragment.show(((SynopsisActivity) mContext).getSupportFragmentManager(), "dialog");

return true;
}
});
}

最佳答案

当我遇到这个问题时,它实际上是由其他异常引起的
我的问题是由启动未导出的 Activity 引起的
解决方案:

  • 检查您传递的参数是否有多个 key
  • 检查是否启动了未设置导出的Activity(用于启动其他应用)
  • 您可以直接设置对 fragment 的引用,而无需通过 传递它们。 bundle
  • 关于java - Android java.lang.IllegalArgumentException : Duplicate key in ArrayMap: null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39306586/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com