添加或删除createChooser选项 [英] add or remove options from createChooser

查看:416
本文介绍了添加或删除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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆