在Android中分享到Facebook,Twitter和电子邮件的URL? [英] Sharing URL to Facebook, Twitter and email in Android?

查看:176
本文介绍了在Android中分享到Facebook,Twitter和电子邮件的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么类似于getsharekit.com的Android?它允许分享URL到社交网站。有没有什么类似的,或者我需要分别为Facebook,Twitter和电子邮件编码?

解决方案

我不知道如果这是您的意思,但您可以使用Android内置的共享菜单...



您可以共享一个URL到Facebook,Twitter,Gmail等因为应用程序安装在您的设备上)使用意图:

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

如果您要共享的应用程序未安装在用户的设备上,例如 - 那么你将不得不使用Facebook SDK。



如果您希望活动处理从其他应用程序共享的文本数据,您可以将其添加到您的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>

希望这有帮助!


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?

解决方案

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!

这篇关于在Android中分享到Facebook,Twitter和电子邮件的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆