我想从我的内部存储中显示一张图片。
这是我的代码:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(getFilesDir()+"/screen.bmp"), "image/*");
startActivity(intent);
它不起作用。应用程序崩溃,logcat 上没有错误。我检查了该文件是否存在。
编辑 1:我认为我的 logcat 有问题。现在我有一个 NullPointerException。
05-26 21:09:13.560: E/AndroidRuntime(10163): FATAL EXCEPTION: main
05-26 21:09:13.560: E/AndroidRuntime(10163): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.gallery/com.android.camera.ViewImage}: java.lang.NullPointerException
05-26 21:09:13.560: E/AndroidRuntime(10163): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
05-26 21:09:13.560: E/AndroidRuntime(10163): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
05-26 21:09:13.560: E/AndroidRuntime(10163): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
05-26 21:09:13.560: E/AndroidRuntime(10163): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
05-26 21:09:13.560: E/AndroidRuntime(10163): at android.os.Handler.dispatchMessage(Handler.java:99)
05-26 21:09:13.560: E/AndroidRuntime(10163): at android.os.Looper.loop(Looper.java:130)
05-26 21:09:13.560: E/AndroidRuntime(10163): at android.app.ActivityThread.main(ActivityThread.java:3835)
05-26 21:09:13.560: E/AndroidRuntime(10163): at java.lang.reflect.Method.invokeNative(Native Method)
05-26 21:09:13.560: E/AndroidRuntime(10163): at java.lang.reflect.Method.invoke(Method.java:507)
05-26 21:09:13.560: E/AndroidRuntime(10163): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
05-26 21:09:13.560: E/AndroidRuntime(10163): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
05-26 21:09:13.560: E/AndroidRuntime(10163): at dalvik.system.NativeStart.main(Native Method)
05-26 21:09:13.560: E/AndroidRuntime(10163): Caused by: java.lang.NullPointerException
05-26 21:09:13.560: E/AndroidRuntime(10163): at com.android.camera.MenuHelper.isWhiteListUri(MenuHelper.java:151)
05-26 21:09:13.560: E/AndroidRuntime(10163): at com.android.camera.ViewImage.onCreate(ViewImage.java:617)
05-26 21:09:13.560: E/AndroidRuntime(10163): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-26 21:09:13.560: E/AndroidRuntime(10163): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)