This is a bug in the Gallery, which is fixed in Cupcake. Also note that with the code you posted, you will end up with a copy of the image on the sd card, so you should either delete the original once you're done, or you should not use insertImage(), but instead insert an entry in to the database, or run the mediascanner so it will pick up the file.
On Mon, Mar 2, 2009 at 7:03 AM, david liu <[email protected]> wrote: > Similar error is happened. Could anyone help? > > On Tue, Feb 24, 2009 at 9:22 AM, Freddy <[email protected]> wrote: >> >> I'm running android sdk v1.1-r1 testing with a T-Mobile G1 device >> HT841GZ04082. >> >> I have a jpg on the sdcard that I want to add to the photo viewer. I >> do this quite simply with the test code >> >> Bitmap bm = BitmapFactory.decodeFile("/sdcard/test.jpg"); >> String test = Images.Media.insertImage(getContentResolver(), bm, >> "title", "desciption"); >> >> which appears to work fine. I receive a value for bm and test is >> "content://media/external/images/media/163" or such. All great to >> this point....yuppie! >> >> Now the problem; when I launch photo viewer from the home screen it >> always crashes until I reset the phone. Here's the crash dump with an >> uncaught exception. I assume this is a bug in the andoid photo >> viewer. Can anyone verify this and/or let me know how else I can add >> an existing jpg to the photo viewer without crashing the app? >> >> Thanks. >> >> >> 02-23 16:47:09.152: ERROR/AndroidRuntime(368): Uncaught handler: >> thread main exiting due to uncaught exception >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): >> java.lang.RuntimeException: Unable to resume activity >> {com.android.camera/com.android.camera.GalleryPicker}: >> java.lang.NullPointerException >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.app.ActivityThread.performResumeActivity(ActivityThread.java: >> 2505) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.app.ActivityThread.handleResumeActivity(ActivityThread.java: >> 2520) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: >> 2160) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.app.ActivityThread.access$1800(ActivityThread.java:112) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1581) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.os.Handler.dispatchMessage(Handler.java:88) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.os.Looper.loop(Looper.java:123) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.app.ActivityThread.main(ActivityThread.java:3739) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> java.lang.reflect.Method.invokeNative(Native Method) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> java.lang.reflect.Method.invoke(Method.java:515) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run >> (ZygoteInit.java:739) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> dalvik.system.NativeStart.main(Native Method) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): Caused by: >> java.lang.NullPointerException >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> com.android.camera.GalleryPicker$GalleryPickerAdapter.init >> (GalleryPicker.java:251) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> com.android.camera.GalleryPicker.rebake(GalleryPicker.java:96) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> com.android.camera.GalleryPicker.onResume(GalleryPicker.java:435) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.app.Instrumentation.callActivityOnResume(Instrumentation.java: >> 1224) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.app.Activity.performResume(Activity.java:3359) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): at >> android.app.ActivityThread.performResumeActivity(ActivityThread.java: >> 2492) >> 02-23 16:47:09.162: ERROR/AndroidRuntime(368): ... 12 more >> >> > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

