Question

I got a problem regarding my app, I have created the camera functionality, but I need that after taking the image, the page should redirect to another activity with having that image.

I have used the following code for camera functionality:

@Override
public void onClick(View v) {
    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
    startActivityForResult(cameraIntent, CAMERA_REQUEST); 
}
Was it helpful?

Solution

 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
            super.onActivityResult(requestCode, resultCode, intent);

            switch (requestCode) {
                    case PICK_FROM_CAMERA:
                if (resultCode == Activity.RESULT_OK) {
                    Bitmap bitmapImage = (Bitmap) intent.getExtras().get("data");
//Redirectin to your second activty passing Bitmap Object
                                  Intent intent = new Intent(getApplicationContext(),
                                SecondActivity.class);
                        intent.putExtra("bitmap", bitmapImage);
                        startActivity(intent);
              }
                  }

in SecondActivity.java

Retrieve that Bitmap like

Bitmap bitImage=getIntent().getParcelableExtra("bitmap");

OTHER TIPS

Override onActivityResult method:

onActivityResult(int reqCode, int respCode, Intent extra)
{
   if(reqCode == CAMERA_REQUEST && respCode == RESULT_OK)
   {
      //Photo has been taken, redirect the user.
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top