Reputation:
I have a simple module of working with the camera. When I use the default camera (in-built camera) it is displaying the thumbnail as required. Anyhow when I use 3rd party camera apps(like candycamera, retrica etc) by using packageManager to take a picture, it doesn't show the thumbnail. it crashes sometimes. I have tried every code within my limits to check that the thumbnail is being displayed but cannot find any relevant solution Help is appreciated Thanks
in onCreate()
private void dispatchPicIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE );
}
}
in onActivityResult()
String timeStamp = new SimpleDateFormat( "yyyyMMdd_HHmmss").format(new Date());
pictureFile = new File(Environment
.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES)
.getAbsolutePath()
+ File.separator + "IMG_" + timeStamp);
try {
FileOutputStream fos = new FileOutputStream(
pictureFile);
Bundle extras = data.getExtras();
Bitmap bm = (Bitmap) extras.get("data");
bm.compress(Bitmap.CompressFormat.JPEG, 90, fos);
fos.close();
filePath = pictureFile.getAbsolutePath();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Upvotes: 0
Views: 93
Reputation: 91
you can use https://github.com/jkwiecien/EasyImage library to take a picture.its easy to understand.
Upvotes: 0
Reputation: 30645
You can use CWAC2 library https://github.com/commonsguy/cwac-cam2 to take a picture. Really useful and easy to understand library.
Upvotes: 0