一起共享图像和文本对于Android上的Telegram不起作用 [英] Sharing Image and Text together is not working for Telegram on android
本文介绍了一起共享图像和文本对于Android上的Telegram不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码在Android中分享图片和文字。当我选择Whatsapp时,它会共享图像和文本,但是当我选择Telegram时,它只是在没有任何文本的情况下共享图像!我的代码有什么问题? Tnx
I'm using the code below to share Image and text in Android. When I choose Whatsapp it shares the image and text together , but when I choose Telegram it just shares Image without any text! What's wrong in my code? Tnx
BitmapDrawable drawable = (BitmapDrawable) imageViewSample .getDrawable();
Bitmap bitmapImg = drawable.getBitmap();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmapImg.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = Images.Media.insertImage(getContext() .getContentResolver(), bitmapImg, "Title", null);
Uri myUri= Uri.parse(path);
try {
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM , myUri);
myBodyText="This is a test.";
share.putExtra(Intent.EXTRA_TEXT , myBodyText);
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
share.setType("image/*");
startActivity(Intent.createChooser(share, "choose app"));
} catch (Exception e) {
e.printStackTrace();
}
推荐答案
它有效。看看我的代码:
It works. Look my code:
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.setType("image/*");
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
BitmapDrawable drawable = (BitmapDrawable) context.getResources().getDrawable(R.drawable.insta_image_j);
Bitmap bitmapImg = drawable.getBitmap();
sharingIntent.putExtra(Intent.EXTRA_STREAM, getLocalBitmapUri(bitmapImg, context));
sharingIntent.putExtra(
android.content.Intent.EXTRA_TEXT,
context.getString(R.string.share_text));
sharingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(sharingIntent, context.getResources().getString(R.string.share_using)));
我将这些行添加到应用程序的onCreate():
And I added these lines to Application's onCreate():
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
这篇关于一起共享图像和文本对于Android上的Telegram不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文