Hi have a java with this code to create sharing intent
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "text" );
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "subject" );
sendIntent.setType("text/plain");
It now creates a popup of available apps and ask if you want to use the chosen app always or just once is there a setting to put it on just once and remove this 2 buttons?
Is there such a option in android like Intent.setOption('just once')?
Thanks
createChooser(intent, title); // Try to invoke the intent. // Define what your app should do if no activity can handle the intent. This displays a dialog with a list of apps that respond to the intent passed to the createChooser() method and uses the supplied text as the dialog title.
Basically what it does is, it lets you set the type of data that you are using to send in an intent. You might also want to check out an existing question: Android - Intent.setType() arguments.
Android uses the action ACTION_SEND to send data from one activity to another, even across process boundaries. You need to specify the data and its type. The system automatically identifies the compatible activities that can receive the data and displays them to the user.
Use
Intent sharingIntent = new Intent ( android.content.Intent.ACTION_SEND );
sharingIntent.setType ( "text/plain" );
sharingIntent.putExtra ( android.content.Intent.EXTRA_TEXT, body.toString () );
startActivity(Intent.createChooser(sharingIntent, "Share using?"));
Instead of
startActivity(sharingIntent);
see example:
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.putExtra(android.content.Intent.EXTRA_TEXT, "Some text");
Intent chooser = Intent.createChooser(sendIntent, "Share Using...");
this.cordova.startActivityForResult(this, chooser, 0);
where the important line in this context is:
Intent chooser = Intent.createChooser(sendIntent, "Share Using...");
This is a convenience technique for wrapping your intents in a "custom" chooser. Alternatively you can start with an ACTION_CHOOSER intent and add a target intent to it as EXTRA_INTENT.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With