Reputation: 3274
I am understanding the code flow of Android Camera available in Android source code. Can anyone please tell me which method in Camera activity is responsible to invoke Camera hardware when we switch on Camera from home activity?
I checked in Camera.java(first activity which is called when user starts camera from home) but did not find any suitable path.
Upvotes: 0
Views: 473
Reputation: 4291
Create an Intent to launch Camera application:
private static final int CAMERA_PIC_REQUEST = 9999; // this can be anything
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
Handle the result got from the Camera:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST) {
Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); // this is the picture taken
}
}
To use the camera in your application you need to request a special permission as well. Put this into your manifest file:
<uses-feature android:name="android.hardware.camera"></uses-feature>
Upvotes: 2