I am working on camera application, where it take a picture and pass it to a another activity as a bitmap.
But the problem is that when I press on "onKeyDown (BACK)" button I get java.lang.NullPointerException error, and the logcat is pointing to this code:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
Intent mIntent = new Intent(this, SecondActivity.class);
>>> Bitmap photo = (Bitmap) data.getExtras().get("data"); <<<
mIntent.putExtra("data", photo);
startActivityForResult(mIntent, 0);
}
How to solve this problem? Everytime when I press on back button and I want to go to my main activity, app has been stopped and got following exception:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Bundle android.content.Intent.getExtras()' on a null object reference
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == event.KEYCODE_BACK);
Intent intent = new Intent(this, FirstActivity.class);
return super.onKeyDown(keyCode, event);
}