本文介绍了如何通过viber和Google环聊共享可绘制图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我通过whatsapp共享图像时,我的代码工作正常....但是对于viber来说,谷歌视频群聊即时通讯出现找不到照片"错误.这是我的代码:
my code works fine when i share a image via whatsapp....but for viber , google hangout im getting "can't find photo" error.this is my code :
int ImageResourse=imageAdapter.mThumbIds[position];
Uri path = Uri.parse("android.resource://dragonflymobile.stickers.lifestickers/" + ImageResourse);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND, path);
((Activity)getActivity()).setResult(Activity.RESULT_OK, shareIntent); //set the file/intent as result
((Activity)getActivity()).finish(); //close your application and get back to the requesting application like GMail and WhatsApp
推荐答案
我找到了不使用FileProvider或android.resource方案的解决方案. thnx CommonsWare用android.resource方案解释情况
i found a solution to this without using FileProvider or android.resource scheme . thnx CommonsWare for explaining the situation with android.resource scheme
int ImageResourse = imageAdapter.mThumbIds[position];
Bitmap bitmapToShare = BitmapFactory.decodeResource(
getResources(), ImageResourse);
File pictureStorage = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File noMedia = new File(pictureStorage, ".nomedia");
if (!noMedia.exists())
noMedia.mkdirs();
File file = new File(noMedia, "shared_image.png");
if (GeneralFunctions.saveBitmapAsFile(bitmapToShare, file)) {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND, Uri.fromFile(file));
((Activity) getActivity()).setResult(Activity.RESULT_OK, shareIntent);
((Activity) getActivity()).finish();
}
else
{
Toast.makeText(getActivity(), "Sending Error", Toast.LENGTH_LONG).show();
}
这篇关于如何通过viber和Google环聊共享可绘制图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!