I am facing a very weird issue. I have an implicit intent for opening the default camera.
There is an image view with a camera icon, which when clicked opens the default camera.
Sometimes on clicking the imageview, opens the camera but sometimes it does not. When I click the back button, it opens the default camera. I am perplexed with this. Is it an issue in my code or device bug.
The image view is in the grid view. As I am creating a grid view of images captured. The first image will be the camera icon and then grid will have the captured images.
I am posting my code:
Manifest permission:
<uses-feature android:name="android.hardware.camera" />
java code:
public void openCamera(String _path, String file_name) {
File file = new File(_path);
if (!file.exists()) {
file.mkdirs();
}
mImageFile = new File(file + file_name);
// create new Intent
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mImageFile));
mActivity.startActivityForResult(intent, 1);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
//user is returning from capturing an image using the camera
if(requestCode == CAMERA_CAPTURE){
//sets the adapter
}
}
}
TRY this And Enjoy