没有默认启动的意图ACTION_SEND

Xei*_*jin 4 android android-intent

我正在尝试使用意图中的ACTION_SEND通过我的应用分享文本.但是,如果您选择使用默认的应用程序,它将与相同的应用程序共享,而不是每次都询问.

有人可以帮我吗?

如果它是可行的,它应该能够通过邮件,脸书,推特,whatsapp分享像这样的代码.谢谢.

Intent textShareIntent = new Intent(Intent.ACTION_SEND);
            textShareIntent.putExtra(Intent.EXTRA_TEXT, "Text to share, URL");
            textShareIntent.setType("text/plain");
            startActivity(textShareIntent);
Run Code Online (Sandbox Code Playgroud)

Sou*_*abh 12

试试这个

Intent textShareIntent = new Intent(Intent.ACTION_SEND);
textShareIntent.putExtra(Intent.EXTRA_TEXT, "Text to share, URL");
textShareIntent.setType("text/plain");
if (textShareIntent.resolveActivity(getPackageManager()) != null)
    startActivity(Intent.createChooser(textShareIntent, "Share"));
else
    // no app can handle this intent, do something else
Run Code Online (Sandbox Code Playgroud)