android小知识之分享

2019-03-02 00:49|来源: 网路

在很多app上都有将某些内容进行分享,不错的功能。

首先是通过使用各个官方的SDK进行指定的分享,找到了一篇文章,写的不错,微信这个可以留给我们模仿完成。

http://blog.csdn.net/yangyu20121224/article/details/9057257

另外就是通过intent传递实现分享,传递个手机上已经安装的应用进行分享,实现起来非常简单,有个缺点,就是不能区分哪些应用本身是不能够进行分享操作的,这个有待改进。

写一个分享按键监听,监听内如下

1  Intent intent=new Intent(Intent.ACTION_SEND);   
2                 intent.setType("image/*");   
3                 intent.putExtra(Intent.EXTRA_SUBJECT, "分享");   
4                 intent.putExtra(Intent.EXTRA_TEXT, title+link);    
5                 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);   
6                 startActivity(Intent.createChooser(intent, getTitle()));

 

 


转自:http://www.cnblogs.com/ws5861/p/3520729

相关问答

更多
  • 也许你想要一个更完整的答案,因为被接受的答案很短,我已经太晚了但是希望它仍然有用:) 所以这是处理多个意图的可能解决方案...... 1)您想知道意图的结果(例如成功或失败)? 只需使用以下行启动意图: startActivityForResult(intent, 1); //instead of startActivity(intent) 并通过重写onActivityResult来检索requestCode和resultCode: @Override public void onActivityRes ...
  • Facebook应用程序不处理EXTRA_SUBJECT或EXTRA_TEXT字段。 这是错误链接: https : //developers.facebook.com/bugs/332619626816423 谢谢@billynomates: 事情是,如果你把一个URL放在EXTRA_TEXT字段中,它可以工作。 这就像他们故意剥离任何文本。 The Facebook application does not handle either the EXTRA_SUBJECT or EXTRA_TEXT fi ...
  • 您必须像这样创建自定义选择器。 public class ShareAdapter extends BaseAdapter { protected static final String TAG = "ShareAdapter"; Intent sendIntent = new Intent(Intent.ACTION_SEND); protected Context context; protected List list = new Array ...
  • 有很多插件可用于此。 我在https://github.com/phonegap/phonegap-plugins上找到了一些东西。 希望这会奏效。 但您需要正确执行相应插件的自述文件中提到的步骤。 there are lot of plugins are available for this. i found something on https://github.com/phonegap/phonegap-plugins. hope this will work. but you need to do ...
  • 哦,你的问题 如果你想为eclipse的非编译库提供.jar文件,你可以使用 https://developers.facebook.com/docs/android/downloads 您可以使用https://origincache.facebook.com/developers/resources/?id=facebook-android-sdk-4.10.1.zip或以上版本进行日食 ohk got your issue if you wanna .jar file for non compile ...
  • 为了更容易理解,只要认为Intent是一个快递,它可以帮助您将数据从Activity1传递到Activity2。 在这种情况下,您可以尝试一种简单的方法:将您的笑话放在一个字符串中: String joke = "Q: What did the butcher say when he backed into the meat-grinder?\n A: Looks like I'm getting a little behind in my work!"; sendIntent.putExtra(Inten ...
  • Google Plus尚未提供公开的API,但https://developers.google.com/+/mobile/android/上提供了一些选项 我强烈建议不要为每个社交网络使用唯一的SDK,因为它们包含很多错误,并且不是很可靠。 如果您只是想将应用程序中的简单文本分享到Facebook,Twitter,Google +等等......我建议创建一个选择器,让用户从他的手机中选择他想要用户共享的应用程序。 它简单,可靠,这通常是在android中完成的。 示例代码: Intent ...
  • 我的代码有什么问题? 可能没什么。 ACTION_SEND在一个Intent支持EXTRA_TEXT 或 EXTRA_STREAM ,而不是两者(“......可以有一个EXTRA_TEXT或EXTRA_STREAM字段,包含要发送的数据”)。 一些ACTION_SEND实现将超出所记录的协议并尝试使用它们。 其他人将坚持使用文档化的协议,只使用一个。 在这种情况下,Facebook可能选择坚持使用文档化的协议,只使用一个。 What's wrong in my code? Probably nothing ...
  • 尝试在代码中添加setContentUrl(“www.example.com”) ShareVideo video = new ShareVideo.Builder().setLocalUrl( Uri.parse("/sdcard/DCIM/cut.mp4")).build(); ShareVideoContent content = new ShareVideoContent.Builder() .setContentUrl("www.ex ...
  • 如果你正在使用facebook android API,你应该这样做 private Facebook mFacebook; private String mMessageToPost; ... function postToWall(urMessageAndLink) { Bundle parameters = new Bundle(); parameters.putString("me ...