私は私のAndroidアプリの中ACTION_VIEWを使用してダウンロードしたJPGファイルを表示しようと恐ろしい時間を持っています。ファイルが存在し、正しいサイズであることを確認できます。私はエミュレータからファイルを取り出してコンピュータ上で開くことができるので、JPGが壊れていないことがわかります。私もView image in ACTION_VIEW intent?のコードを試してみました。次のようにACTION_VIEWを使用してダウンロードしたJPGを表示できますか?
私のコードは次のとおりです。
// start intent to view the file
String filename = "test.jpg"
String downloadsDirectoryPath = getFilesDir().getPath() + "/downloads";
File file = new File(downloadsDirectoryPath + "/" + filename);
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(file), "image/*");
startActivity(i);
それはまっすぐでなければなりませんようにこれはそうですが、私は上記のコードを実行するたびに、私はここで何が起こっているかについて
ERROR/UriImage(336): got exception decoding bitmap
ERROR/UriImage(336): java.lang.NullPointerException
ERROR/UriImage(336): at com.android.camera.Util.makeInputStream(Util.java:336)
ERROR/UriImage(336): at com.android.camera.Util.makeBitmap(Util.java:307)
ERROR/UriImage(336): at com.android.camera.Util.makeBitmap(Util.java:299)
ERROR/UriImage(336): at com.android.camera.gallery.UriImage.fullSizeBitmap(UriImage.java:94)
ERROR/UriImage(336): at com.android.camera.gallery.UriImage.fullSizeBitmap(UriImage.java:86)
ERROR/UriImage(336): at com.android.camera.gallery.UriImage.thumbBitmap(UriImage.java:120)
ERROR/UriImage(336): at com.android.camera.ImageGetter$ImageGetterRunnable.executeRequest(ImageGetter.java:173)
ERROR/UriImage(336): at com.android.camera.ImageGetter$ImageGetterRunnable.run(ImageGetter.java:149)
ERROR/UriImage(336): at java.lang.Thread.run(Thread.java:1096)
任意のアイデアを得ます?
あなたはコメントのためにあなたのAndroidManifest.xml –
おかげでandroid.permission.INTERNETあなたを追加しました:
(アプリケーションに応じて)より良い解決策は、これらのいずれかを使用することが考えられます。はい、私はマニフェストでそれを持っています。私は実際にファイルがエミュレータにあることを確認することができます。私は自分の問題がjpgファイルではなくパーミッションに関連していることを理解しました。説明については、他の答えに対する私の回答を参照してください。 –