2

我想实现一个“告诉朋友”动作,我有这个代码:

            Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(Intent.EXTRA_SUBJECT, getApplicationContext().getString(R.string.app_name));
            shareIntent.putExtra(Intent.EXTRA_TEXT, getApplicationContext().getString(R.string.sharefriendtext));
            startActivity(Intent.createChooser(shareIntent, getApplicationContext().getString(R.string.sharefriend)));

当“选择器”对话框打开时,我会看到一长串应用程序(例如,包括添加到Dropbox,条形码扫描仪,翻译...)。我注意到 Whatsapp 告诉朋友功能将选择范围缩小到几乎仅限于消息传递应用程序(不存在添加到 Dropbox)。我怎样才能达到相同的结果?

4

1 回答 1

0
Intent i=new Intent(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(android.content.Intent.EXTRA_SUBJECT,"Subject test");
i.putExtra(android.content.Intent.EXTRA_TEXT, "extra text that you want to put");
startActivity(Intent.createChooser(i,"Share via"));
于 2013-06-16T17:03:49.123 回答