2014-07-09 83 views
-1

在我的應用我想從圖庫中選擇一個圖片提供:畫廊拋出NullPointerException異常而Intent.ACTION_PICK

Intent pickPhoto = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 
startActivityForResult(pickPhoto , 1); 

但有時Android的畫廊停止。展望未過濾的日誌,我有以下的錯誤(注:錯誤沒有在我的代碼,該系統投吧):

橙色

07-09 09:28:09.993: W/dalvikvm(22510): VFY: unable to resolve static method 1391: Landroid/sec/multiwindow/MultiWindow;.createInstance (Landroid/app/Activity;)Landroid/sec/multiwindow/MultiWindow; 
07-09 09:28:09.993: D/dalvikvm(22510): VFY: replacing opcode 0x71 at 0x001a 
07-09 09:28:10.008: I/dalvikvm(22510): Could not find method android.sec.multiwindow.MultiWindow.createInstance, referenced from method com.sec.android.gallery3d.util.GalleryUtils.setMultiWindow 
07-09 09:28:10.008: W/dalvikvm(22510): VFY: unable to resolve static method 1391: Landroid/sec/multiwindow/MultiWindow;.createInstance (Landroid/app/Activity;)Landroid/sec/multiwindow/MultiWindow; 
07-09 09:28:10.008: D/dalvikvm(22510): VFY: replacing opcode 0x71 at 0x001a 
07-09 09:28:10.024: W/System.err(22510): android.content.pm.PackageManager$NameNotFoundException: com.skp.tcloud.agent 
07-09 09:28:10.024: W/System.err(22510): at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:102) 
07-09 09:28:10.024: W/System.err(22510): at com.sec.android.gallery3d.tCloud.TCloudRefer.isTCloudAgentExist(TCloudRefer.java:39) 
07-09 09:28:10.024: W/System.err(22510): at com.sec.android.gallery3d.util.GalleryFeature.checkUseTCloud(GalleryFeature.java:882) 
07-09 09:28:10.024: W/System.err(22510): at com.sec.android.gallery3d.util.GalleryFeature.init(GalleryFeature.java:294) 
07-09 09:28:10.024: W/System.err(22510): at com.sec.android.gallery3d.app.GalleryAppImpl.getDataManager(GalleryAppImpl.java:205) 
07-09 09:28:10.024: W/System.err(22510): at com.sec.android.gallery3d.provider.GalleryProvider.onCreate(GalleryProvider.java:124) 
07-09 09:28:10.024: W/System.err(22510): at android.content.ContentProvider.attachInfo(ContentProvider.java:1058) 
07-09 09:28:10.024: W/System.err(22510): at android.app.ActivityThread.installProvider(ActivityThread.java:4981) 
07-09 09:28:10.024: W/System.err(22510): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4593) 
07-09 09:28:10.024: W/System.err(22510): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4533) 
07-09 09:28:10.024: W/System.err(22510): at android.app.ActivityThread.access$1400(ActivityThread.java:150) 
07-09 09:28:10.024: W/System.err(22510): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340) 
07-09 09:28:10.024: W/System.err(22510): at android.os.Handler.dispatchMessage(Handler.java:99) 
07-09 09:28:10.024: W/System.err(22510): at android.os.Looper.loop(Looper.java:175) 
07-09 09:28:10.024: W/System.err(22510): at android.app.ActivityThread.main(ActivityThread.java:5279) 
07-09 09:28:10.024: W/System.err(22510): at java.lang.reflect.Method.invokeNative(Native Method) 
07-09 09:28:10.024: W/System.err(22510): at java.lang.reflect.Method.invoke(Method.java:511) 
07-09 09:28:10.024: W/System.err(22510): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 
07-09 09:28:10.024: W/System.err(22510): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 
07-09 09:28:10.024: W/System.err(22510): at dalvik.system.NativeStart.main(Native Method) 

一些日誌行紅色

07-09 09:16:21.876: E/AndroidRuntime(20732): FATAL EXCEPTION: main 
07-09 09:16:21.876: E/AndroidRuntime(20732): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sec.android.gallery3d/com.sec.android.gallery3d.app.Gallery}: java.lang.NullPointerException 
07-09 09:16:21.876: E/AndroidRuntime(20732): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at android.app.ActivityThread.access$700(ActivityThread.java:150) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at android.os.Handler.dispatchMessage(Handler.java:99) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at android.os.Looper.loop(Looper.java:175) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at android.app.ActivityThread.main(ActivityThread.java:5279) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at java.lang.reflect.Method.invokeNative(Native Method) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at java.lang.reflect.Method.invoke(Method.java:511) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at dalvik.system.NativeStart.main(Native Method) 
07-09 09:16:21.876: E/AndroidRuntime(20732): Caused by: java.lang.NullPointerException 
07-09 09:16:21.876: E/AndroidRuntime(20732): at com.sec.samsung.gallery.controller.StartGalleryViewCmd.processIntent(StartGalleryViewCmd.java:98) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at com.sec.samsung.gallery.controller.StartGalleryViewCmd.execute(StartGalleryViewCmd.java:60) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at org.puremvc.java.core.Controller.executeCommand(Controller.java:138) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at org.puremvc.java.core.Controller$1.onNotification(Controller.java:174) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at org.puremvc.java.patterns.observer.Observer.notifyObserver(Observer.java:87) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at org.puremvc.java.core.View.notifyObservers(View.java:134) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at org.puremvc.java.patterns.facade.Facade.notifyObservers(Facade.java:376) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at org.puremvc.java.patterns.facade.Facade.sendNotification(Facade.java:336) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at org.puremvc.java.patterns.facade.Facade.sendNotification(Facade.java:350) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at com.sec.android.gallery3d.app.Gallery.processIntent(Gallery.java:805) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at com.sec.android.gallery3d.app.Gallery.startView(Gallery.java:776) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at com.sec.android.gallery3d.app.Gallery.startView(Gallery.java:758) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at com.sec.android.gallery3d.app.Gallery.onCreate(Gallery.java:232) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at android.app.Activity.performCreate(Activity.java:5283) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) 
07-09 09:16:21.876: E/AndroidRuntime(20732): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209) 
07-09 09:16:21.876: E/AndroidRuntime(20732): ... 11 more 

爲什麼會發生80%的次數?

回答

1

試試這種方式,希望這會幫助你解決你的問題。

final private int PICK_IMAGE_USER_AVATAR = 1; 

Intent intent = new Intent(); 
intent.setType("image/*"); 
intent.setAction(Intent.ACTION_GET_CONTENT); 
startActivityForResult(Intent.createChooser(intent, ""), PICK_IMAGE_USER_AVATAR); 
+0

謝謝!似乎它解決了這個問題,但它允許打開任何類型的文件,不僅像圖庫中的圖像:/ –

相關問題