androidの实现分享功能

来源:互联网 发布:能货到付款的淘宝网 编辑:程序博客网 时间:2024/06/10 19:03


android实现分享功能,几行代码就可以实现了,EXTRA_TEXT参数的值就是要分享的内容,直接上代码

intent=new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, "分享"); intent.putExtra(Intent.EXTRA_TEXT, text);  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, getTitle()));

分享图片类型的的话只需要修改type值

        Intent intent=new Intent(Intent.ACTION_SEND);           intent.setType("image/*");           intent.putExtra(Intent.EXTRA_SUBJECT, "分享");           intent.putExtra(Intent.EXTRA_TEXT, "终于可以了!!!");            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);           startActivity(Intent.createChooser(intent, getTitle()));   


0 0
原创粉丝点击