通过Facebook,Twitter,电子邮件和消息共享应用程序只 [英] Share Application Through Facebook, Twitter, Email, and Messaging Only
问题描述
我想分享通过Facebook,Twitter,电子邮件和短信我的申请。我不想与那些使用共享按钮时psented $ P $其他选项分享。
I want to share my application via Facebook, Twitter, email, and messaging. I do not want to share it with the other options that are presented when using the share button.
我目前使用以下code的分享按钮:
I am currently using the following code for the share button:
sharebuton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String TEXT = "I shared the file " + " via MyApp";
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, TEXT);
startActivity(Intent.createChooser(sendIntent, "Share the program:"));
}
});
在使用本code用户与其他选项psented共享,如Gmail,记事本,窥视,蓝牙等,以及四个选项上面提到的应用程序$ P $。
When using this code the user is presented with other options to share the application like Gmail, Notepad, Peep, Bluetooth, etc. as well as the four options mentioned above.
是否有可能使得只有四个选项(Facebook,微博,电子邮件和短信)是psented用户$ P $来筛选股票期权?
Is it possible to filter the share options so that only the four options (Facebook, Twitter, email, and messaging) are presented to the user?
推荐答案
不知道,如果你还在寻找一个答案,但我最近遇到我自己的解决方案,你想要做什么,而是完全相反 - 我想创建的应用程序自定义列表,用户可以通过排除Facebook的分享。你需要知道那些你希望排除应用程序的包名/包括。这里是我的code基本上需要注册后处理ACTION_SEND命令可用的软件包列表,然后你可以选择你想要显示的列表中的项目。
Not sure if you're still looking for an answer but I recently come across my own solution for exactly what you're trying to do, but the exact opposite - I wanted to create a custom list of applications the user could share with by excluding Facebook. You'll need to know the package names of those apps you wish to exclude/include. Here's my code which basically takes a list of available packages registered to handle the ACTION_SEND command and then you can choose which items in the list you want to display.
List<Intent> targetedShareIntents = new ArrayList<Intent>();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(intent, 0);
if (!resInfo.isEmpty()) {
for (ResolveInfo resolveInfo : resInfo) {
String packageName = resolveInfo.activityInfo.packageName;
Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
targetedShareIntent.setType("image/jpeg");
targetedShareIntent.putExtra(Intent.EXTRA_TITLE, "Title string");
targetedShareIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject string");
if ("com.facebook.katana".equals(packageName) || "com.facebook.orca".equals(packageName)) {
// don't add Facebook or Facebook messenger app to list
continue;
} else {
targetedShareIntent.putExtra(Intent.EXTRA_TEXT, bodyStr);
}
targetedShareIntent.setPackage(packageName);
targetedShareIntents.add(targetedShareIntent);
}
Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), getString(R.string.results_share_title));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));
startActivity(chooserIntent);
}
这篇关于通过Facebook,Twitter,电子邮件和消息共享应用程序只的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!