Sharing URL to Facebook, Twitter and email in Android?

前端 未结 7 1188
野趣味
野趣味 2021-01-30 16:16

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

7条回答
  •  一向
    一向 (楼主)
    2021-01-30 16:54

    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:

    
        
            
            
            
        
    
    

    Hope this helps!

提交回复
热议问题