首页 > 解决方案 > 如何了解 Android Studio Bundle 中的“关键”是什么?

问题描述

我正在使用一个不是最新的库。( https://github.com/notsukamto/GFIPhotoPicker ) 它有一个 onActivityResult 函数来获取活动结果。它用这个函数返回一个意图

    if (selection != null) {
        intent.putExtra(EXTRA_SELECTION, new LinkedList<>(selection));
    }

    public static List<Uri> getSelection(Intent data) {
    return data.getParcelableArrayListExtra(EXTRA_SELECTION);}

所以我的问题是这个 Parcelable 的关键是什么以及我如何正确地获得这个意图?(我试过“EXTRA_SELECTION”但不起作用)

Bundle[
  {com.github.potatodealer.gfiphotopicker.activity.extra.SELECTION=
       [file:///storage/emulated/0/DCIM/Camera/IMG_20190114_072919.jpg, 
       file:///storage/emulated/0/DCIM/Camera/IMG_20190114_072904.jpg,       
       file:///storage/emulated/0/DCIM/Camera/IMG_20190114_072848.jpg], 

com.github.potatodealer.gfiphotopicker.activity.extra.FACEBOOK_SELECTION=[],

com.github.potatodealer.gfiphotopicker.activity.extra.INSTAGRAM_SELECTION=[]
    }

]

标签: javaandroidandroid-intentbundleparcelable

解决方案


如果您在提供的 github 链接中访问此目录EXTRA_SELECTION,则每个活动中都会有一个常量。

例如,如果我们单击FacebookPreviewActivity.java,我们会看到:

private static final String EXTRA_SELECTION = FacebookPreviewActivity.class.getPackage().getName() + ".extra.SELECTION";


推荐阅读