Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing URL to Facebook, Twitter and email in Android?

Is there anything similar to getsharekit.com for Android? It allows to share URL's to social networking sites. Is there anything similar to this or do I need to code separately for facebook, Twitter and email?

like image 925
sunil Avatar asked Nov 01 '10 06:11

sunil


People also ask

How to share URL in Android?

You can share a URL to Facebook, Twitter, Gmail and more (as long as the apps are installed on your device) using Intents: Intent i = new Intent(Intent. ACTION_SEND); i. setType("text/plain"); i.

How do I share a link on Facebook Android?

Then use the following code to share link on the facebook. ShareDialog shareDialog; FacebookSdk. sdkInitialize(Activity. this); shareDialog = new ShareDialog(act); ShareLinkContent linkContent = new ShareLinkContent.


2 Answers

I don't know if that's what you mean but you can use the Android built-in sharing menu...

You can share a URL to Facebook, Twitter, Gmail and more (as long as the apps are installed on your device) using Intents:

Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL"); i.putExtra(Intent.EXTRA_TEXT, "http://www.url.com"); startActivity(Intent.createChooser(i, "Share URL")); 

If the app you want to share to is not installed on the user's device, for example - facebook, then you'll have to use Facebook SDK.

If you want your Activity to handle text data shared from other apps as well, you can add this to your AndroidManifest.xml:

<activity android:name=".ShareLink">     <intent-filter>         <action android:name="android.intent.action.SEND" />         <category android:name="android.intent.category.DEFAULT" />         <data android:mimeType="text/plain" />     </intent-filter> </activity> 

Hope this helps!

like image 117
Lior Iluz Avatar answered Oct 09 '22 09:10

Lior Iluz


You can use also ShareCompat class from support library.

ShareCompat.IntentBuilder(context)     .setType("text/plain")     .setChooserTitle("Share URL")     .setText("http://www.url.com")     .startChooser(); 

https://developer.android.com/reference/android/support/v4/app/ShareCompat.html

like image 43
lukjar Avatar answered Oct 09 '22 09:10

lukjar