最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
android开发使用ACTION_SEND完美共享图片和文本实例
时间:2014-12-27 编辑:简简单单 来源:一聚教程网
我想使用 ACTION_SEND 共享图片+文字,我运行了下面的代码,暂时只能共享图片,无法共享文字,我如何才能共享?
代码如下 | 复制代码 |
private Uri imageUri; private Intent intent; imageUri = Uri.parse("android.resource://" + getPackageName() + "/drawable/" + "ic_launcher"); intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, "Hello"); intent.putExtra(Intent.EXTRA_STREAM, imageUri); intent.setType("image/*"); startActivity(intent); |
//如何才能共享图片?
处理方法
你可以共享下面的代码:
代码如下 | 复制代码 |
String shareBody = "Here is the share content body"; Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_using))); |
所以你的全部代码(图片+文本)需要变成
代码如下 | 复制代码 |
private Uri imageUri; private Intent intent; imageUri = Uri.parse("android.resource://" + getPackageName() + "/drawable/" + "ic_launcher"); intent = new Intent(Intent.ACTION_SEND); //text intent.putExtra(Intent.EXTRA_TEXT, "Hello"); //image intent.putExtra(Intent.EXTRA_STREAM, imageUri); //type of things intent.setType("*/*"); //sending startActivity(intent); |
相关文章
- sora软件价格介绍 02-22
- sora官网入口地址一览 02-22
- Sora生成的视频使用教程 02-22
- 《梦幻西游》元宵灯谜线索答案大全2024 02-22
- 《原神》有朋自远方来第一天通关攻略 02-22
- 《苏醒之路》四个结局达成攻略 02-22