Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent ACTION_SEND without default launch

I'm trying to share a text by my app using ACTION_SEND in the intent. But if you choose using an app for default, it will share with the same app without asking everytime.

Can someone help me with it?

if it's posible, it should be able to share via mail, facebook, twitter, whatsapp like this code do. Thanks.

Intent textShareIntent = new Intent(Intent.ACTION_SEND);
            textShareIntent.putExtra(Intent.EXTRA_TEXT, "Text to share, URL");
            textShareIntent.setType("text/plain");
            startActivity(textShareIntent);
like image 870
Xeijin Avatar asked Dec 14 '22 07:12

Xeijin


1 Answers

Try this

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
like image 143
Sourabh Avatar answered Jan 02 '23 14:01

Sourabh