添加或删除createChooser选项 [英] add or remove options from createChooser
问题描述
String message = "Text I want to share";
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(share,"Share on"));
现在它显示像默认选项:蓝牙,电子邮件,Facebook和Gmail中,LinkedIn的消息,分享通过条形码code
或者是这些已安装的应用程序?
or are these the installed apps?
我想是知道的,我怎么可以从这个名单中删除一些。像我想删除分享通过条形码code
。
what i want is to know, how i can remove few from this list. like i want to remove Share Via Barcode
.
和添加其他什么东西?
感谢您
推荐答案
使用低于code到一个新的项目添加到选择屏幕。
Use below code to add a new Item to the Chooser Screen.
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);
Intent addIntent = ;//whatever you want
Intent chooser = new Intent(Intent.ACTION_CHOOSER);
chooser.putExtra(Intent.EXTRA_INTENT, share );
chooser.putExtra(Intent.EXTRA_TITLE, "title");
Intent[] intentArray = {addIntent };
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
startActivity(chooser);
不过,除去特定项目是不可能的。所以,你可以解决使用意图<一href="http://developer.android.com/reference/android/content/pm/PackageManager.html#resolveActivity%28android.content.Intent,%20int%29">Packagemanager.resolveActivity并创建自己的自定义列表视图
But removing specific items is not possible. So you could resolve the intent using Packagemanager.resolveActivity and create your own custom list view
这篇关于添加或删除createChooser选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!