Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何通过viber和google hangout共享可绘制图像?_Android_Hangout_Viber - Fatal编程技术网

Android 如何通过viber和google hangout共享可绘制图像?

Android 如何通过viber和google hangout共享可绘制图像?,android,hangout,viber,Android,Hangout,Viber,当我通过whatsapp共享图像时,我的代码运行良好……但对于viber,google hangout im出现“找不到照片”错误。 这是我的代码: int ImageResourse=imageAdapter.mThumbIds[position]; Uri path = Uri.parse("android.resource://dragonflymobile.stickers.lifestickers/" + ImageResour

当我通过whatsapp共享图像时,我的代码运行良好……但对于viber,google hangout im出现“找不到照片”错误。 这是我的代码:

                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

很少有应用程序支持
android.resource
方案


欢迎您使用
内容
方案共享内容,例如通过
文件提供商
,因为更多的应用程序将支持这一点。

我找到了一个解决方案,无需使用文件提供商或安卓资源方案。thnx Commonware用于解释android.resource方案的情况

                    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();
                        }