转自: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 uris = new ArrayList();  
  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. }  

更多相关文章

  1. Android 读取配置文件的内容
  2. Android 获取扫码枪的扫描内容
  3. android按行读取文件内容的几个方法
  4. Android提高篇内容整理
  5. ListView 输入法框遮挡内容
  6. Android 标题下的内容折叠效果
  7. Android 在弹出Dialog(带EditText)的同时弹出软键盘并且EditText中
  8. android读取短信内容 自动填充验证码
  9. Android 建立文件夹、生成文件并写入文本文件内容

随机推荐

  1. Android中自定义switch控件样式
  2. Android理解:显式和隐式Intent
  3. Android中子布局填充ScrollView
  4. 【Android】AIDL介绍和实例讲解
  5. 把应用跑在android上
  6. android 将鼠标右键点击事件改为点击后返
  7. Android 中文 SDK —— ADT 14.0.0 (ADT14
  8. ToggleButton自定义View学习
  9. Android探索之旅(第三十二篇)Android 每日g
  10. Android(ViewPager中的ViewPager)ViewPager