如何分享图片+文字的机器人使用ACTION_SEND? [英] How to Share Image+Text using ACTION_SEND in android?
本文介绍了如何分享图片+文字的机器人使用ACTION_SEND?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想分享文字+图片使用ACTION_SEND在Android中,我使用低于code,我只能共享图片,但我不能分享它的文字,
I want to share Text + Image using ACTION_SEND in android, i am using below code, i can share only Image but i can not share Text with it,
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);
您可以请提供解决方案?
Can you please provide solutions ?
推荐答案
您可以通过以下方式分享纯文本这些codeS
you can share plain text by these codes
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)));
让你充分code(图像+文字)成为
so your full code (your image+text) becomes
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);
我刚刚更换图像/ *
与 * / *
更新
Uri imageUri = Uri.parse("android.resource://" + getPackageName()
+ "/drawable/" + "ic_launcher");
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "Hello");
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/jpeg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "send"));
这篇关于如何分享图片+文字的机器人使用ACTION_SEND?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文