Intent intent = new Intent(Intent.ACTION_PICK, null);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", int_Width_crop);
intent.putExtra("outputY", int_Height_crop);
intent.putExtra("scale", false);
intent.putExtra("return-data", true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri());
// Uri imagePath = getImageUri();
startActivityForResult(intent, CHOOSE_PICTURE);
------------------------------------------------------------------------------------------
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST)
{
Uri imagePath = getImageUri();
// System.out.println("Activity result"+imagePath);
}
if (requestCode == CROP_FROM_CAMERA)
{
final Bundle extras = data.getExtras();
if (extras != null) {
Bitmap photo = extras.getParcelable("data");
// mPhoto = photo;
// mPhotoChanged = true;
myImage.setImageBitmap(photo);
// setPhotoPresent(true);
}
}
if (requestCode == CHOOSE_PICTURE)
{
final Bundle extras = data.getExtras();
if (extras != null) {
Log.d("photo", "extras is not null");
Uri selectedImage = getImageUri();
getContentResolver().notifyChange(selectedImage, null);
ContentResolver cr = getContentResolver();
Bitmap bitmap;
try {
bitmap = android.provider.MediaStore.Images.Media
.getBitmap(cr, selectedImage);
Log.d("photo",
"data.getAction() is not null. setting image.");
this.myImage.setImageBitmap(bitmap);
} catch (Exception e) {
Toast.makeText(this, "Failed to load",
Toast.LENGTH_SHORT).show();
Log.e("photo", e.toString());
}
}
}
Android Training in Kerala
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", int_Width_crop);
intent.putExtra("outputY", int_Height_crop);
intent.putExtra("scale", false);
intent.putExtra("return-data", true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri());
// Uri imagePath = getImageUri();
startActivityForResult(intent, CHOOSE_PICTURE);
------------------------------------------------------------------------------------------
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST)
{
Uri imagePath = getImageUri();
// System.out.println("Activity result"+imagePath);
}
if (requestCode == CROP_FROM_CAMERA)
{
final Bundle extras = data.getExtras();
if (extras != null) {
Bitmap photo = extras.getParcelable("data");
// mPhoto = photo;
// mPhotoChanged = true;
myImage.setImageBitmap(photo);
// setPhotoPresent(true);
}
}
if (requestCode == CHOOSE_PICTURE)
{
final Bundle extras = data.getExtras();
if (extras != null) {
Log.d("photo", "extras is not null");
Uri selectedImage = getImageUri();
getContentResolver().notifyChange(selectedImage, null);
ContentResolver cr = getContentResolver();
Bitmap bitmap;
try {
bitmap = android.provider.MediaStore.Images.Media
.getBitmap(cr, selectedImage);
Log.d("photo",
"data.getAction() is not null. setting image.");
this.myImage.setImageBitmap(bitmap);
} catch (Exception e) {
Toast.makeText(this, "Failed to load",
Toast.LENGTH_SHORT).show();
Log.e("photo", e.toString());
}
}
}
Android Training in Kerala
0 comments: