nat*_*rio 8 android android-intent kotlin google-photos document-provider
我不知道为什么会发生这种情况,但是我无法从Google相册提供者中选择图片。在API 27上进行测试。
如果我使用:
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.addCategory(Intent.CATEGORY_OPENABLE)
intent.type = "image/*"
Run Code Online (Sandbox Code Playgroud)
当我打开“照片”提供程序并浏览文件夹时,会看到很多这样的文件:
2019-03-02 12:04:15.164 17641-13395/? W/NetworkManagementSocketTagger: untagSocket(120) failed with errno -22
2019-03-02 12:04:22.528 13217-13217/? E/ResourceType: Style contains key with bad entry: 0x01010586
2019-03-02 12:04:22.535 13217-13217/? W/ResourceType: For resource 0x7f020366, entry index(870) is beyond type entryCount(468)
Run Code Online (Sandbox Code Playgroud)
当我单击图片时,我看到以下内容:
2019-03-02 12:04:34.150 13217-13217/? W/ResourceType: For resource 0x7f02036c, entry index(876) is beyond type entryCount(468)
2019-03-02 12:04:34.151 13217-13217/? W/ResourceType: For resource 0x7f02036c, entry index(876) is beyond type entryCount(468)
2019-03-02 12:04:34.229 2907-16891/? W/MediaExtractor: FAILED to autodetect media content.
2019-03-02 12:04:34.569 10839-10839/? W/ResourceType: ResTable_typeSpec entry count inconsistent: given 468, previously 1330
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我什至没有在提供商抽屉中看到Google相册。
如何解决这个问题,最好使用ACTION_GET_CONTENT?
ACTION_PICK将提供选择图像的选项,您可以获得文件路径
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Image.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
Intent sIntent = new Intent("com.sec.android.app.myfiles.PICK_DATA");
sIntent.addCategory(Intent.CATEGORY_DEFAULT);
sIntent.setType("image/*");
Intent chooserIntent;
if (getPackageManager().resolveActivity(sIntent, 0) != null) {
// it is device with samsung file manager
chooserIntent = Intent.createChooser(sIntent, "Select file");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{intent});
} else {
chooserIntent = Intent.createChooser(intent, "Select file");
}
try {
startActivityForResult(chooserIntent, REQUEST_TAKE_GALLERY_VIDEO);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(), "No suitable File Manager was found.", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
638 次 |
最近记录: |