2016-11-08 10 views
3

最近、Android Nougatをサポートするためにadobecreativesdkを最新バージョンに更新しました。私は、エディタで画像を編集した後、私はonActivityResultに次のコードを使用して編集したビットマップを取得しよう:BitmapFactory.decodeFile()がAdobeImageIntent.EXTRA_OUTPUT_URIと連携しない

mImageUri = data.getParcelableExtra(AdobeImageIntent.EXTRA_OUTPUT_URI); 

        Bitmap bitmap = BitmapFactory.decodeFile(mImageUri.getPath()); 

        if(bitmap!=null) 
        { 

        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); 
        imagebytes = baos.toByteArray(); 

        PlayAnimation(); 
        } 

私はdata.getDataを(使用した最新バージョンに更新)の代わりに、data.getParcelableExtraと、その前にAndroid Marshmallowでうまくいきました。しかし、私のビットマップは常にnullとして返されます。私は画像のURIを、この投稿でどのように述べられているかのように設定しました: https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en。 BitmapFactory.Optionsを使ってビットマップのサイズを変更しようとしたところ、画像が大きすぎるかもしれないと考えました。しかしそれは事実ではないようです。

+0

'mImageUri.getPath()'パスを教えてください。コンテンツシムの一部である可能性があります。 – greenapps

答えて

1

あなたがイメージにUriを持っている場合、ContentResolverを経由して、それを読むために優れている:

Uri uri; 
Context context; 
try { 
    Bitmap bm = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri)); 
} catch (FileNotFoundException e) { 
    e.printStackTrace(); 
} 

ContentResolverはあなたのための基盤となるストレージの違いを処理します。それはfile://,content://と他のUriタイプの両方で同じように機能します。

+0

はいこれが問題を解決しました:)ありがとう – nexus

関連する問題