Can someone help me with this?
I'm really having a hard time to understand why this error is happening... my code is simple as:

        File imageFile = new File(thenPicPath);
        if(imageFile.exists()){
                Bitmap myBitmap = BitmapFactory.decodeFile(thenPicPath);
ImageView returnpic = (ImageView) findViewById (R.id.addinfopic);
                returnpic.setImageBitmap(myBitmap);
                }else{
                        Context context = getApplicationContext();
                        CharSequence text = "nao existe essa foto!";
                        int duration = Toast.LENGTH_SHORT;

                        Toast toast = Toast.makeText(context, text, duration);
                        toast.show();
                }

When I get to the "returnpic.setImageBitmap(myBitmap);" part it crashes and gives this error on the logcat: (PS: the variable thenPicPath is ok being sdcard/downloads/something.jpg)


09-01 15:29:03.357: ERROR/AndroidRuntime(5057): Uncaught handler: thread main exiting due to uncaught exception 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): java.lang.RuntimeException: Unable to start activity ComponentInfo {com.pedroteixeira.thennnow/com.pedroteixeira.thennnow.addPicInfo}: java.lang.NullPointerException 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2401) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2417) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at android.app.ActivityThread.access$2100(ActivityThread.java:116) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at android.os.Handler.dispatchMessage(Handler.java:99) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at android.os.Looper.loop(Looper.java:123) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at android.app.ActivityThread.main(ActivityThread.java:4203) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at java.lang.reflect.Method.invokeNative(Native Method) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at java.lang.reflect.Method.invoke(Method.java:521) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:791) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at dalvik.system.NativeStart.main(Native Method) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): Caused by: java.lang.NullPointerException 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at com.pedroteixeira.thennnow.addPicInfo.onCreate(addPicInfo.java:99) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: 1123) 09-01 15:29:03.367: ERROR/AndroidRuntime(5057): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2364)
09-01 15:29:03.367: ERROR/AndroidRuntime(5057):     ... 11 more


On Aug 31, 2010, at 4:26 PM, Pedro Teixeira wrote:

Hi there...
I'm having an issue with a Bitmap which is giving me an error but any
kind of report so I can understand it..
The code is simpley this this:

- I get a image path from a bundle:
       Bundle w = getIntent().getExtras();
        final String thenPicPath= w.getString("oldpicpath");

- And I set it on a ImageView called returnpic:
       Bitmap oldPicture = BitmapFactory.decodeFile(thenPicPath);
       returnpic.setImageBitmap(oldPicture);


In the debugger the String thenPicPath reads : /sdcard/download/
7122gato.jpg
And the oldPicture Bitmap reads: android.graphics.bit...@437700c0

Everything looks fine but I get and error when setting the
imagebitmap.. any clue?

--
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

Pedro Teixeira

www.pedroteixeira.org

--
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

Reply via email to