Android - 如何使用删除选项打开图库中的图像
Android - how to open image in gallery with delete option
我使用以下代码打开图库中的图片:
public void onItemClicked(PictureItem item){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imageUri = FileProvider.getUriForFile(getApplicationContext(), "myapp.fileprovider", new File(item.uri.getPath()));
intent.setDataAndType(imageUri, "image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
}
这显示了我在图库中的照片,但处于 'read-only' 模式。我希望能够从那里删除图像,就像我直接在图库中打开它一样。
我必须为此使用哪个操作?我不想使用选择,只是带有删除选项的普通视图。我试过 ACTION_EDIT
但它不受支持(也不是正确的选择......)。
I use following code to open an image in the gallery
首先,Android.
有数百个 "gallery" 个应用程序可用
其次,您的代码只是要求查看图像(由于您的通配符 MIME 类型,Intent
已损坏)。没有要求响应的应用程序是 "gallery" 应用程序。
I want to be able to delete the image from there, just as if I opened it directly in the gallery.
然后在您自己的应用中自己实施,并删除 ACTION_VIEW
Intent
.
Which action do I have to use for that?
没有 Intent
操作表明 "please display this image, but only if you are a gallery app, and, oh, by the way, you must offer a delete option",这似乎是您想要的。
我使用以下代码打开图库中的图片:
public void onItemClicked(PictureItem item){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imageUri = FileProvider.getUriForFile(getApplicationContext(), "myapp.fileprovider", new File(item.uri.getPath()));
intent.setDataAndType(imageUri, "image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
}
这显示了我在图库中的照片,但处于 'read-only' 模式。我希望能够从那里删除图像,就像我直接在图库中打开它一样。
我必须为此使用哪个操作?我不想使用选择,只是带有删除选项的普通视图。我试过 ACTION_EDIT
但它不受支持(也不是正确的选择......)。
I use following code to open an image in the gallery
首先,Android.
有数百个 "gallery" 个应用程序可用其次,您的代码只是要求查看图像(由于您的通配符 MIME 类型,Intent
已损坏)。没有要求响应的应用程序是 "gallery" 应用程序。
I want to be able to delete the image from there, just as if I opened it directly in the gallery.
然后在您自己的应用中自己实施,并删除 ACTION_VIEW
Intent
.
Which action do I have to use for that?
没有 Intent
操作表明 "please display this image, but only if you are a gallery app, and, oh, by the way, you must offer a delete option",这似乎是您想要的。