如何在没有app崩溃的情况下在三星galaxy note2上打开Gallery?

时间:2015-04-16 08:07:07

标签: android gallery

我想打开图库以浏览我的应用中的图片。我的代码是:

Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("content://media/internal/images/media"));
startActivity(intent);

它在许多手机上运行良好,但在note2上,它会因为这样的NullPointerException而崩溃:

04-16 16:05:01.275: E/AndroidRuntime(11998): FATAL EXCEPTION: main
04-16 16:05:01.275: E/AndroidRuntime(11998): java.lang.NullPointerException
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.samsung.gallery.view.detailview.DetailViewState.onCreate(DetailViewState.java:762)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.samsung.gallery.model.ViewStateProxy.startState(ViewStateProxy.java:60)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.samsung.gallery.controller.StartStateCmd.execute(StartStateCmd.java:27)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.core.Controller.executeCommand(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.core.Controller$1.onNotification(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.observer.Observer.notifyObserver(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.core.View.notifyObservers(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.facade.Facade.notifyObservers(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.facade.Facade.sendNotification(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.facade.Facade.sendNotification(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.samsung.gallery.controller.ViewerStartCmd.execute(ViewerStartCmd.java:107)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.core.Controller.executeCommand(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.core.Controller$1.onNotification(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.observer.Observer.notifyObserver(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.core.View.notifyObservers(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.facade.Facade.notifyObservers(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.facade.Facade.sendNotification(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.facade.Facade.sendNotification(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.samsung.gallery.controller.StartGalleryViewCmd$2.run(StartGalleryViewCmd.java:163)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at android.app.Activity.runOnUiThread(Activity.java:4762)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.samsung.gallery.controller.StartGalleryViewCmd.startImageViewMode(StartGalleryViewCmd.java:157)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.samsung.gallery.controller.StartGalleryViewCmd.processIntent(StartGalleryViewCmd.java:115)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.samsung.gallery.controller.StartGalleryViewCmd.execute(StartGalleryViewCmd.java:53)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.core.Controller.executeCommand(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.core.Controller$1.onNotification(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.observer.Observer.notifyObserver(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.core.View.notifyObservers(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.facade.Facade.notifyObservers(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.facade.Facade.sendNotification(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at org.puremvc.java.patterns.facade.Facade.sendNotification(Unknown Source)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.android.gallery3d.app.Gallery.processIntent(Gallery.java:543)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.android.gallery3d.app.Gallery.access$000(Gallery.java:57)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.sec.android.gallery3d.app.Gallery$3$1.run(Gallery.java:508)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at android.os.Handler.handleCallback(Handler.java:615)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at android.os.Handler.dispatchMessage(Handler.java:92)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at android.os.Looper.loop(Looper.java:137)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at android.app.ActivityThread.main(ActivityThread.java:4898)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at java.lang.reflect.Method.invokeNative(Native Method)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at java.lang.reflect.Method.invoke(Method.java:511)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
04-16 16:05:01.275: E/AndroidRuntime(11998):    at dalvik.system.NativeStart.main(Native Method)

谁对此有任何想法?uri错误吗?

1 个答案:

答案 0 :(得分:1)

你试过这个解决方案吗?

android get real path by Uri.getPath()

然后从String方法获取Uri。