码迷,mamicode.com
首页 > 其他好文 > 详细

用Intent分享的代码

时间:2015-09-14 19:47:14      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

  1. private void share(String content, Uri uri){  

  2.     Intent shareIntent = new Intent(Intent.ACTION_SEND);   

  3.     if(uri!=null){  

  4.         shareIntent.putExtra(Intent.EXTRA_STREAM, uri);  

  5.         shareIntent.setType("image/*");   

  6.         //当用户选择短信时使用sms_body取得文字  

  7.         shareIntent.putExtra("sms_body", content);  

  8.     }else{  

  9.         shareIntent.setType("text/plain");   

  10.     }  

  11.     shareIntent.putExtra(Intent.EXTRA_TEXT, content);  

  12.     //自定义选择框的标题  

  13.     //startActivity(Intent.createChooser(shareIntent, "邀请好友"));  

  14.     //系统默认标题  

  15.     startActivity(shareIntent);  

  16. }  


用Intent分享的代码

标签:

原文地址:http://my.oschina.net/u/1463920/blog/505980

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!