Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(new File(path));
intent.setDataAndType(uri, "image/*");
startActivity(intent);
当路径为/mnt/sdcard/aaa.png时,相同的代码可以显示图像。虽然路径是data / data / com.test / aaa.png但是图像无法显示。是否需要一些权限。我已经在路径中下载了它。 错误就像
解析图像时
09-12 11:54:31.448: ERROR/UriImage(545): got exception decoding bitmap
09-12 11:54:31.448: ERROR/UriImage(545): java.lang.NullPointerException
09-12 11:54:31.448: ERROR/UriImage(545): at com.android.camera.Util.makeInputStream(Util.java:336)
09-12 11:54:31.448: ERROR/UriImage(545): at com.android.camera.Util.makeBitmap(Util.java:307)
09-12 11:54:31.448: ERROR/UriImage(545): at com.android.camera.Util.makeBitmap(Util.java:299)
09-12 11:54:31.448: ERROR/UriImage(545): at com.android.camera.gallery.UriImage.fullSizeBitmap(UriImage.java:94)
09-12 11:54:31.448: ERROR/UriImage(545): at com.android.camera.gallery.UriImage.fullSizeBitmap(UriImage.java:86)
09-12 11:54:31.448: ERROR/UriImage(545): at com.android.camera.gallery.UriImage.thumbBitmap(UriImage.java:120)
09-12 11:54:31.448: ERROR/UriImage(545): at com.android.camera.ImageGetter$ImageGetterRunnable.executeRequest(ImageGetter.java:173)
09-12 11:54:31.448: ERROR/UriImage(545): at com.android.camera.ImageGetter$ImageGetterRunnable.run(ImageGetter.java:149)
09-12 11:54:31.448: ERROR/UriImage(545): at java.lang.Thread.run(Thread.java:1019)
09-12 11:54:31.828: ERROR/UriImage(545): got exception decoding bitmap
09-12 11:54:31.828: ERROR/UriImage(545): java.lang.NullPointerException
09-12 11:54:31.828: ERROR/UriImage(545): at com.android.camera.Util.makeInputStream(Util.java:336)
09-12 11:54:31.828: ERROR/UriImage(545): at com.android.camera.Util.makeBitmap(Util.java:307)
09-12 11:54:31.828: ERROR/UriImage(545): at com.android.camera.Util.makeBitmap(Util.java:299)
09-12 11:54:31.828: ERROR/UriImage(545): at com.android.camera.gallery.UriImage.fullSizeBitmap(UriImage.java:94)
09-12 11:54:31.828: ERROR/UriImage(545): at com.android.camera.ImageGetter$ImageGetterRunnable.executeRequest(ImageGetter.java:204)
09-12 11:54:31.828: ERROR/UriImage(545): at com.android.camera.ImageGetter$ImageGetterRunnable.run(ImageGetter.java:149)
09-12 11:54:31.828: ERROR/UriImage(545): at java.lang.Thread.run(Thread.java:1019)
解析apk文件时
09-12 12:01:41.307: WARN/PackageParser(1298): Skipping dir: /data/data/com.download.activity/files/aaa.apk
09-12 12:01:41.307: WARN/PackageInstaller(1298): Parse error when parsing manifest. Discontinuing installation.
答案 0 :(得分:0)
您是否设置了访问SD卡的权限?