我是Android开发的新手。
打开Intent.ACTION_GET_CONTENT
时是否可以删除两个按钮(始终/仅一次)?
这是我目前的代码。
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent,PICK);
答案 0 :(得分:13)
我找到了实现这个目标的方法:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
Intent openInChooser = Intent.createChooser(intent, "Open in...");
startActivityForResult(openInChooser,PICK);
答案 1 :(得分:0)
这是系统生成的对话框,因此您无法对其进行更改。
您可以使用queryIntentActivities()
获取可以响应您意图的应用列表,然后根据您的喜好在没有按钮的情况下在自己的对话框中显示它们。
答案 2 :(得分:0)
关键是创建一个Intent.createChooser()
,如果您调用Intent.createChooser()
,并将其传递给您的Intent对象,则它将返回您的intent版本,该版本将始终显示选择器。
示例:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my awesome text to share.");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Share via"));