问题
Any reason android skip the chooser dialog(as screenshot below) and direct go to one specific app(e.g. WhatsApp) when sharing a text/plain
type data externally?
It works well in image/jpeg
type of data, and this issue only happens in certain device.
String share = Html.fromHtml(node.getString("Msg")).toString();
Intent intent2 = new Intent(Intent.ACTION_SEND);
intent2.setType("text/plain");
intent2.putExtra(Intent.EXTRA_TEXT, share);
startActivity(Intent.createChooser(intent2, getResources().getString(R.string.SendTo)));
回答1:
There are two possibilities: there's only one app that can handle "text/plain" on your phone, or you selected an app as the default app to handle that type of intents. If it's the second case, you can go to system settings of that app to "clear defaults"
回答2:
Your code is correct ... Possibly you have set a default app to open such content and hence the intent chooser does not come.
Alternatively, try to set other extras also like :
intent2.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
回答3:
If you want to show chooser dialog alwayas then you have to create chooser yourself while starting Intent. Like.
Intent i = new Intent(yourAction);
startActivity(Intent.createChooser(i, "title"));
来源:https://stackoverflow.com/questions/33491138/android-chooser-dialog-skipped-while-sharing-text-type-data-to-external-app