Android intent 仅在“上显示邮件应用程序”;“告诉朋友”;共享意图
我想实现“告诉朋友”操作,我有以下代码:Android intent 仅在“上显示邮件应用程序”;“告诉朋友”;共享意图,android-intent,Android Intent,我想实现“告诉朋友”操作,我有以下代码: Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent
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)。
如何获得相同的结果?非常相似的代码没有达到我想要的结果
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"));