1

I want to launch Android built-in camera app with a thumbnail icon on the right-bottom. Here is my code to open the camera app.

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);

I think I need to put a intent data to do it. I look forward to your help.

Thanks.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
sunghun
  • 1,424
  • 4
  • 25
  • 49

1 Answers1

1

Just create an image button, or button or anything you desire really.

In the onclick event add something like:

    String saveFileName= Environment.getExternalStorageDirectory() + "/test.png";

    // BUILT IN CAMERA 
    Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
    camera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(saveFileName) );   
    this.startActivityForResult(camera, 1);

Make sure you have necessary permissions set. Like saving to the SDCard.

You are very close, you dont need those flags set. And you should ideally specify where you are saving the image. If you are wondering how to make the button take a look here

Community
  • 1
  • 1
IAmGroot
  • 13,760
  • 18
  • 84
  • 154