Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement share via option in android?

I want to implement something like this. share via

It should not be hard coded. If user haven't installed Dropbox there should not be a option to share via Dropbox.

Thanks in advance !

like image 596
Chrishan Avatar asked Dec 29 '11 07:12

Chrishan


People also ask

How do I change share options on Android?

Use Sharedr for More Share Menu Options Tap the Invoke Share Dialog button and you'll see an Android prompt to choose Android System or Sharedr. Choose the latter, followed by Always to set it as the default. Now, you'll see the Sharedr interface anytime you tap the share button around your phone.


2 Answers

You can do the same by using:

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"));

Detailed example is here for your reference: http://mobile.tutsplus.com/tutorials/android/android-sdk-implement-a-share-intent/

like image 199
Paresh Mayani Avatar answered Oct 12 '22 10:10

Paresh Mayani


For Sharing the Content Via:

Intent shareIntent =  new Intent(android.content.Intent.ACTION_SEND); 

//set type  

shareIntent.setType("text/plain");  

//add what a subject you want

shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"add what a subject you want");  

 String shareMessage="message body"; 

//message  

shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,shareMessage); 

//start sharing via 

startActivity(Intent.createChooser(shareIntent,"Sharing via"));  
like image 20
Gaurav Lambole Avatar answered Oct 12 '22 09:10

Gaurav Lambole