android 简单的分享方法

除了使用oauth认证然后调用各大平台的接口分享外还有一种简单的方法可以实现分享功能。

缺点是需要用户手机上已经安装了那些客户端

    Intent intent=new Intent(Intent.ACTION_SEND);  
    intent.setType("text/plain");  //纯文本

    /*图片分享

    it.setType("image/png");

     //添加图片
     File f = new File(Environment.getExternalStorageDirectory()
       +"/Pictures/2.png");
     Uri u = Uri.fromFile(f);
     it.putExtra(Intent.EXTRA_STREAM, u);

     */
    intent.putExtra(Intent.EXTRA_SUBJECT, "分享");  
    intent.putExtra(Intent.EXTRA_TEXT, "I would like to share this with you...");  
    startActivity(Intent.createChooser(intent, getTitle()));  
posted @ 2012-07-20 14:56  lipeil  阅读(224)  评论(0编辑  收藏  举报