Android:QQ分享、微信分享、朋友圈分享(不使用第三方SDK)

转自:http://blog.csdn.net/HMYANG314/article/details/41939845

一、分享到QQ

[java]  view plain  copy
  1. /** 
  2.      * 分享到QQ好友 
  3.      *  
  4.      */  
  5.     private void shareToQQFriend() {  
  6.         Intent intent = new Intent();  
  7.         ComponentName componentName = new ComponentName("com.tencent.mobileqq""com.tencent.mobileqq.activity.JumpActivity");  
  8.         intent.setComponent(componentName);  
  9.         intent.setAction(Intent.ACTION_SEND);  
  10.         intent.setType("text/*");  
  11.         intent.putExtra(Intent.EXTRA_TEXT, "这是分享内容");  
  12.         startActivity(intent);  
  13.     }  

二、分享到微信朋友

[java]  view plain  copy
  1. /** 
  2.      * 分享信息到朋友 
  3.      *  
  4.      */  
  5.     private void shareToWxFriend() {  
  6.         Intent intent = new Intent();  
  7.         ComponentName componentName = new ComponentName("com.tencent.mm""com.tencent.mm.ui.tools.ShareImgUI");  
  8.         intent.setComponent(componentName);  
  9.         intent.setAction(Intent.ACTION_SEND);  
  10.         intent.setType("text/*");  
  11.         intent.putExtra(Intent.EXTRA_TEXT, "这是分享内容");  
  12.         intent.putExtra(Intent.EXTRA_STREAM, "http://www.weixin.com");  
  13.         startActivity(intent);  
  14.     }  

三、分享到朋友圈

[java]  view plain  copy
  1. /** 
  2.  * 分享信息到朋友圈 
  3.  *  
  4.  * @param file 
  5.  *            ,假如图片的路径为path,那么file = new File(path); 
  6.  */  
  7. private void shareToTimeLine(File file) {  
  8.     Intent intent = new Intent();  
  9.     ComponentName componentName = new ComponentName("com.tencent.mm""com.tencent.mm.ui.tools.ShareToTimeLineUI");  
  10.     intent.setComponent(componentName);  
  11.       
  12.     intent.setAction(Intent.ACTION_SEND);  
  13.     intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));  
  14.       
  15.     // intent.setAction(android.content.Intent.ACTION_SEND_MULTIPLE);  
  16.     // ArrayList<Uri> uris = new ArrayList<Uri>();  
  17.     // for (int i = 0; i < images.size(); i++) {  
  18.     // Uri data = Uri.fromFile(new File(thumbPaths.get(i)));  
  19.     // uris.add(data);  
  20.     // }  
  21.     // intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);  
  22.       
  23.     intent.setType("image/*");  
  24.       
  25.     startActivity(intent);  
  26. }  

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值