0

私のコードは、whatsapp 経由で画像を共有すると正常に動作します....しかし、viber の場合、Google ハングアウトで「写真が見つかりません」というエラーが発生します。これは私のコードです:

                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
4

2 に答える 2

1

FileProvider または android.resource scheme を使用せずにこれに対する解決策を見つけました。android.resourceスキームで状況を説明するためのthnx CommonsWare

                    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();
                        }
于 2014-08-30T08:45:00.950 に答える
0

android.resourceこのスキームをサポートするアプリは、あるとしてもほとんどありません。

より多くのアプリがそれをサポートするため、content経由などのスキームを使用して物事を共有することを歓迎します。FileProvider

于 2014-08-15T22:16:08.843 に答える