Reputation: 550
is there any way to override the onBAckPressed() for camera activity i.e android.provider.MediaStore.ACTION_IMAGE_CAPTURE.
Let me explain what I m trying to do
I have a button when user clicks that a dialog appears which asks the user to either select picture from gallery or capture image using camera.
so the code is like this
case R.id.btn_live:
Intent liveIntent= new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(liveIntent,RESULT_CAPTURE_IMAGE);
myDialog.dismiss();
break;
case R.id.btn_gallery:
Intent galIntent = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galIntent, RESULT_LOAD_IMAGE);
myDialog.dismiss();
break;
now suppose user selects any of the two actions then we start that using intent like this -
Intent liveIntent= new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
The user enters into an the camera activity , now when the user is using camera , i want to apply some functionality if he presses back button.
so how will i do it? any thoughts?
Upvotes: 2
Views: 998
Reputation: 22306
you cant override methods in external activities you are calling. However, when a user hits back in an activity that was called using startActivityForResult the response code RESULT_CANCELLED is generally returned (there may be instances where this isn't true). In your onActivityResult method simply check for the RESULT_CANCELLED code and call whatever functionality you need
Upvotes: 4