I was trying to load the image and set as background of the app. What i
tried is

    {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK && requestCode == 0) {
    Uri photo = data.getData();
    ContentResolver resolver = getContentResolver();
    resolver.notifyChange(photo, null);

    try {
    Bitmap bitmap = MediaStore.Images.Media.getBitmap(resolver,
    photo);
    FrameLayout bg = (FrameLayout) findViewById(R.id.frame);
    Drawable drawable = new BitmapDrawable(getResources(),
    bitmap);
    bg.setBackgroundDrawable(drawable);

    // Do something useful with your bitmap
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    }

And it crashes as soon as i select the picture to load. Here is the logcat
error

    11-06 04:04:15.002: E/AndroidRuntime(446): java.lang.RuntimeException:
Failure delivering result ResultInfo{who=null, request=0, result=-1,
data=Intent { dat=content://media/external/images/media/1 }} to activity
{org.example.opengl/org.example.opengl.OpenGL}:
java.lang.NullPointerException
    11-06 04:04:15.002: E/AndroidRuntime(446): at
android.app.ActivityThread.deliverResults(ActivityThread.java:3515)

Any idea? Thanks in advance.

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