Select 图片仅来自画廊 android
Select Image only from Gallery android
我正在使用以下代码打开图片库 selection
private void galleryIntent() {
Intent intent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.select_file)), SELECT_FILE);
一切正常,但它第一次给出了一个带有两个选项的弹出窗口 select:
我能否让我的应用程序始终直接打开图库而没有任何此类弹出窗口?
谢谢
每个图库应用程序都有自己的包名称,该名称可能因设备而异。要执行您想要的操作,您必须知道图库应用程序的包名称。某些设备甚至可能没有默认图库应用。
您所做的是正确的做法,用户可以决定将图库应用设置为默认应用。除非有非常重要或特殊的原因,否则把选择权交给用户是比较合理的。
看看Launching Gallery in android phones
试试这个...
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),
PICK_IMAGE_REQUEST);
试试这个:-
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/internal/images/media"))
startActivity(intent);
否则你可以试试这个...
Intent intent = new Intent();
intent.setType("image/*");
startActivity(intent);
在 Android 10 上 ACTION_PICK 的意图打开图库
Intent().apply {
action = Intent.ACTION_PICK
type = "image/*"
}
当带有 ACTION_GET_CONTENT 的意图打开文件选择器时
Intent().apply {
action = Intent.ACTION_GET_CONTENT
type = "image/*"
}
我正在使用以下代码打开图片库 selection
private void galleryIntent() {
Intent intent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.select_file)), SELECT_FILE);
一切正常,但它第一次给出了一个带有两个选项的弹出窗口 select:
我能否让我的应用程序始终直接打开图库而没有任何此类弹出窗口?
谢谢
每个图库应用程序都有自己的包名称,该名称可能因设备而异。要执行您想要的操作,您必须知道图库应用程序的包名称。某些设备甚至可能没有默认图库应用。
您所做的是正确的做法,用户可以决定将图库应用设置为默认应用。除非有非常重要或特殊的原因,否则把选择权交给用户是比较合理的。
看看Launching Gallery in android phones
试试这个...
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),
PICK_IMAGE_REQUEST);
试试这个:-
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/internal/images/media"))
startActivity(intent);
否则你可以试试这个...
Intent intent = new Intent();
intent.setType("image/*");
startActivity(intent);
在 Android 10 上 ACTION_PICK 的意图打开图库
Intent().apply {
action = Intent.ACTION_PICK
type = "image/*"
}
当带有 ACTION_GET_CONTENT 的意图打开文件选择器时
Intent().apply {
action = Intent.ACTION_GET_CONTENT
type = "image/*"
}