Image displays when choosing from gallery but not when capturing from camera - java

On the press of a button, dispatchTakePictureIntent() lets the user choose between taking a picture or choosing one from the gallery four times. These four URIs are stored in an ArrayList and the four should be shown in their respective ImageViews. The problem I'm having is that when I "capture a picture", it doesn't show in the ImageView right away; but the pictures I chose from gallery do.
The picture I captured is properly saved and can be found in "choose from gallery" the next time I press the button. Can anybody see what I'm doing wrong?
takePictureIntent():
private void dispatchTakePictureIntent() {
for(int i = 0; i < 4; i++) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = createImageFile();
outputFileUri = Uri.fromFile(photoFile);
} catch (IOException ex) {
Log.w("error","IOException");
}catch (NullPointerException nullEx) {
Log.w("error","NullPointerException");
}
// Camera.
final List<Intent> cameraIntents = new ArrayList<Intent>();
final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
final PackageManager packageManager = getPackageManager();
final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
for (ResolveInfo res : listCam) {
final String packageName = res.activityInfo.packageName;
final Intent intent = new Intent(captureIntent);
intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
intent.setPackage(packageName);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
cameraIntents.add(intent);
}
// Filesystem.
final Intent galleryIntent = new Intent();
galleryIntent.setType("image/*");
galleryIntent.setAction(Intent.ACTION_OPEN_DOCUMENT);
// Chooser of filesystem options.
final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source");
// Add the camera options.
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()]));
if(id.equals(HAPPY_ID))
startActivityForResult(chooserIntent, REQUEST_HAPPY_PHOTO);
if(id.equals(SURPRISED_ID))
startActivityForResult(chooserIntent, REQUEST_SURPRISED_PHOTO);
if(id.equals(AFRAID_ID))
startActivityForResult(chooserIntent, REQUEST_AFRAID_PHOTO);
if(id.equals(UPSET_ID))
startActivityForResult(chooserIntent, REQUEST_UPSET_PHOTO);
if(id.equals(SAD_ID))
startActivityForResult(chooserIntent, REQUEST_SAD_PHOTO);
}
}
}
onActivityResult():
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_HAPPY_PHOTO || requestCode == REQUEST_SURPRISED_PHOTO || requestCode == REQUEST_AFRAID_PHOTO ||
requestCode == REQUEST_UPSET_PHOTO || requestCode == REQUEST_SAD_PHOTO) {
final boolean isCamera;
if (data == null) {
isCamera = true;
} else {
final String action = data.getAction();
if (action == null) {
isCamera = false;
} else {
isCamera = action.equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
}
}
Uri selectedImageUri;
if (isCamera) {
selectedImageUri = outputFileUri;
} else {
selectedImageUri = data == null ? null : data.getData();
}
//Log.d("doing ids", "right before id");
//Log.d("doing ids", "id is " + id);
if(requestCode == REQUEST_HAPPY_PHOTO) {
//Log.d("doing ids", "in happy");
happyList.add(selectedImageUri);
}
if(requestCode == REQUEST_SURPRISED_PHOTO) {
//Log.d("doing ids", "in surprised");
surprisedList.add(selectedImageUri);
}
if(requestCode == REQUEST_AFRAID_PHOTO) {
//Log.d("doing ids", "in surprised");
afraidList.add(selectedImageUri);
}
if(requestCode == REQUEST_UPSET_PHOTO) {
//Log.d("doing ids", "in surprised");
upsetList.add(selectedImageUri);
}
if(requestCode == REQUEST_SAD_PHOTO) {
//Log.d("doing ids", "in surprised");
sadList.add(selectedImageUri);
}
}
}
}

Try this, this works for me
public Uri captureImage() {
Intent chooserIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (chooserIntent.resolveActivity(getPackageManager()) != null) {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, "Image File name");
Uri takenImageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
Intent intentPicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intentPicture.putExtra(MediaStore.EXTRA_OUTPUT, takenImageUri);
startActivityForResult(intentPicture, MyConstants.REQUEST_IMAGE_CAPTURE);
return takenImageUri;
}
return null;
}
public String getRealPathFromURI(Uri contentUri){
try {
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
catch (Exception e){
return contentUri.getPath();
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && data != null) {
switch (requestCode){
case MyConstants.REQUEST_IMAGE_CAPTURE:
if (takenImageUri != null) {
Uri imagePath =getRealPathFromURI(takenImageUri,this));
}
}
}
}

rather than looping for 4 times, why not make each imageView an OnClickListener to get the image one by one?

Related

Restrict selecting file above some size in Android Studio

I a beginner in android, I want to select an image or a video file. But I want to restrict the selected file size, let's assume the restriction size is 5MB. Above 5MB I want to not allow the user to select the file.
How can I do it?
Any help would be appreciated.
Button OnClick:
btnSelectFile.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
final Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
galleryIntent.setType("*/*");
startActivityForResult(galleryIntent, 21);
}
});
OnActivityResult:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 21 && resultCode == RESULT_OK) {
// Get the Uri of the selected file
uri = data.getData();
uriString = uri.toString();
myFile = new File(uriString);
path = myFile.getAbsolutePath();
displayName = null;
if (uriString.startsWith("content://")) {
Cursor cursor = null;
try {
cursor = getActivity().getContentResolver().query(uri, null, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
displayName = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);
Log.e("TAG","Size: "+Long.toString(cursor.getLong(sizeIndex)));
textFileSelected.setText(displayName);
fileName = textFileSelected.getText().toString();
Toast.makeText(this, "File Selected: " + fileName, Toast.LENGTH_SHORT).show();
}
} finally {
cursor.close();
}
} else if (uriString.startsWith("file://")) {
displayName = myFile.getName();
textFileSelected.setText(displayName);
fileName = textFileSelected.getText().toString();
Toast.makeText(this, "File Selected: " + fileName, Toast.LENGTH_SHORT).show();
}
}
}

Insert a picture into an imageview

In my app, I insert two pictures into two image-views and I use activity for result to fetch the photo from gallery.
private void showFileChooser () {
mHandler.post(new Runnable() {
#Override
public void run() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
}
});
}
private void showFileChooser2 () {
mHandler.post(new Runnable() {
#Override
public void run() {
Intent intent2 = new Intent();
intent2.setType("image/*");
intent2.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent2, "Select Picture"), PICK_IMAGE_REQUEST2);
}
});
}
#Override
protected void onActivityResult ( int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
Uri filePath = data.getData();
try {
//Getting the Bitmap from Gallery
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
rbitmap = getResizedBitmap(bitmap, 1000);//Setting the Bitmap to ImageView
imageViewUserImage.setImageBitmap(rbitmap);
imageViewUserImage.requestFocus();
} catch (IOException e) {
e.printStackTrace();
}
}else if (requestCode == PICK_IMAGE_REQUEST2 && resultCode == RESULT_OK && data != null && data.getData() != null) {
Uri filePath2 = data.getData();
try {
//Getting the Bitmap from Gallery
bitmap2 = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath2);
rbitmap2 = getResizedBitmap(bitmap2, 1000);//Setting the Bitmap to ImageView
imageViewUserImage2.setImageBitmap(rbitmap2);
imageViewUserImage2.requestFocus();
} catch (IOException e) {
e.printStackTrace();
}
}
}
The app is doing well but sometimes a weird thing happens.Sometimes once I click the desired photo in gallery, the app returns to the main activity and I find the previous loaded image in the other image-view is deleted.In other words, sometimes loading a picture in one of them deletes the loaded image in the other.
That glitch doesn't happen always, it sometimes happens and sometimes the app works well without any problem.
How can I fix that?
Place a break point in the catch on the 'e.printStackTrace();' line.
Play with the app, and see the reason for failure.
Without any stack trace we can only guess the reason.
I found the problem.The size of the images are kind of large so a "memory is out" error appears.To avoid such problem, I recycled each bitmap within its if case.
private void showFileChooser () {
mHandler.post(new Runnable() {
#Override
public void run() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
}
});
}
private void showFileChooser2 () {
mHandler.post(new Runnable() {
#Override
public void run() {
Intent intent2 = new Intent();
intent2.setType("image/*");
intent2.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent2, "Select Picture"), PICK_IMAGE_REQUEST2);
}
});
}
#Override
protected void onActivityResult ( int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
Uri filePath = data.getData();
try {
//Getting the Bitmap from Gallery
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
rbitmap = getResizedBitmap(bitmap, 1000);//Setting the Bitmap to ImageView
imageViewUserImage.setImageBitmap(rbitmap);
bitmap.recycle;
imageViewUserImage.requestFocus();
} catch (IOException e) {
e.printStackTrace();
}
}else if (requestCode == PICK_IMAGE_REQUEST2 && resultCode == RESULT_OK && data != null && data.getData() != null) {
Uri filePath2 = data.getData();
try {
//Getting the Bitmap from Gallery
bitmap2 = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath2);
rbitmap2 = getResizedBitmap(bitmap2, 1000);//Setting the Bitmap to ImageView
imageViewUserImage2.setImageBitmap(rbitmap2);
bitmap2.recycle;
imageViewUserImage2.requestFocus();
} catch (IOException e) {
e.printStackTrace();
}
}
}

Take picture from camera and pass URI to another activity

When I try to get the URI on the onActivityResult() method, I get a null pointer exception.
I need to take a picture from the device camera and then pass the URI to the next activity.
That's my actual code:
public void takePicFromCamera(View view){
if (Build.VERSION.SDK_INT >= 24) {
try {
Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
m.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
}
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), "IMG_FOLDER");
imageUri = Uri.fromFile(new File(mediaStorageDir.getPath() + File.separator +
"profile_img.jpg"));
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, 2);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1 && resultCode != 0) {
Uri sel_img = data.getData();
Intent intent = new Intent(MainActivity.this, RateActivity.class);
intent.putExtra("uri", sel_img.toString());
startActivity(intent);
}
if(requestCode == 2 && resultCode != 0){
Intent intent = new Intent(MainActivity.this, RateActivity.class);
intent.putExtra("uri", imageUri.toString());
startActivity(intent);
}
}
The RateActivity after I take the image, doesn't start

Capture photo intent resultCode

How can I detect wether the user take picture and selects it (with the confirm button on camera) or they just turn on a camera, take a picture and remove it (with the cancel button on camera)
When the user take picture I am loading that picture into an ImageView. If user hits confirm button then everything is OK but if user don't want that picture and decide to hit cancel button then the ImageView goes blank.
This is my camera intent :
void capturePhoto() {
// ImagePicker.pickImage(this, "Select your image:");
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
// Create the File where the photo should go
File f = null;
try {
f = setUpPhotoFile();
mCurrentPhotoPath = f.getAbsolutePath();
Uri photoURI = Uri.fromFile(f);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
} catch (IOException e) {
e.printStackTrace();
f = null;
mCurrentPhotoPath = null;
pictureUri = null;
}
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
}
And onActivityResult, in both cases the resultCode is always 1. (note that RESULT_OK is -1) and I dont know why.
This is how I set image to ImageView using Glide:
Glide.with(this).load(mCurrentPhotoPath).centerCrop().into(imageView);
Any Suggestions?
Thanks!
you just need to pass if statement in onActivityresult
cause if you use directly that URI or whatever you use which has no any frame set cause user cancel it so just do as given
//if needed than
//public static final int RESULT_OK = -1;
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case REQUEST_TAKE_PHOTO:
//do your stuff here
}
}
You can use below code
static final int REQUEST_IMAGE_CAPTURE = 1;
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
if (isCameraPermissionEnabled()) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.CAMERA},
1);
}
}
}
public boolean isCameraPermissionEnabled() {
return !(Build.VERSION.SDK_INT >= 23 &&
ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED );
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
mBitmap = (Bitmap) extras.get("data");
imageView.setBackground(new BitmapDrawable(getResources(),mBitmap));
}
}
//For more information https://developer.android.com/training/camera/photobasics.html

why Image can return to previous activity but not intent to new activity

Why image can be pass to previous activity but not intent to new activity?
ImageFitScreen.java
b = (ImageView) findViewById(R.id.imageView3);
public void selectImage() {
final CharSequence[] options = { "Take Photo", "Choose from Gallery","Cancel" };
AlertDialog.Builder builder = new AlertDialog.Builder(ImageFitScreen.this);
builder.setTitle("Add Photo!");
builder.setItems(options, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int item) {
if (options[item].equals("Take Photo"))
{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File f = new File(android.os.Environment.getExternalStorageDirectory(), "temp.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
//pic = f;
// Toast.makeText(getApplicationContext(), Uri.fromFile(f) +"", Toast.LENGTH_LONG).show();
startActivityForResult(intent, 1);
} else if (options[item].equals("Choose from Gallery"))
{
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 2);
} else if (options[item].equals("Cancel")) {
dialog.dismiss();
finish();
}
}
});
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == 1) {
//h=0;
File f = new File(Environment.getExternalStorageDirectory().toString());
for (File temp : f.listFiles()) {
if (temp.getName().equals("temp.jpg")) {
f = temp;
File photo = new File(Environment.getExternalStorageDirectory(), "temp.jpg");
//pic = photo;
break;
}
}
try {
Bitmap bitmap;
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
bitmapOptions.inJustDecodeBounds = false;
bitmapOptions.inPreferredConfig = Bitmap.Config.RGB_565;
bitmapOptions.inDither = true;
bitmapOptions.inSampleSize=8;
bitmap = BitmapFactory.decodeFile(f.getAbsolutePath(), bitmapOptions);
Global.img = bitmap;
b.setImageBitmap(bitmap);
String path = android.os.Environment.getExternalStorageDirectory() + File.separator + "Phoenix" + File.separator + "default";
//p = path;
f.delete();
OutputStream outFile = null;
File file = new File(path, String.valueOf(System.currentTimeMillis()) + ".jpg");
try {
outFile = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 85, outFile);
//pic=file;
outFile.flush();
outFile.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
} else if (requestCode == 2) {
Uri selectedImage = data.getData();
// h=1;
//imgui = selectedImage;
String[] filePath = {MediaStore.Images.Media.DATA};
Cursor c = getContentResolver().query(selectedImage, filePath, null, null, null);
c.moveToFirst();
int columnIndex = c.getColumnIndex(filePath[0]);
String picturePath = c.getString(columnIndex);
c.close();
Bitmap thumbnail = (BitmapFactory.decodeFile(picturePath));
Log.w("path of image ******", picturePath + "");
b.setImageBitmap(thumbnail);
}
}
else
{
finish();
}
}
ok.setOnClickListener(new View.OnClickListener() //back to Project1.java
{
public void onClick(View arg0)
{
Intent returnIntent=new Intent();
text=t.getText().toString();
b.setDrawingCacheEnabled(true);
b.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
b.layout(0, 0, b.getMeasuredWidth(), b.getMeasuredHeight());
b.buildDrawingCache(true);
returnIntent.putExtra("text", text);
if (b.getDrawingCache() != null) {
Bitmap bitmap = Bitmap.createBitmap(b.getDrawingCache());
if (bitmap == null) {
Log.e("TAG", "getDrawingCache() == null");
}
Global.img = bitmap;
}
setResult(Activity.RESULT_OK, returnIntent);
finish();
}
});
Project1.java
public void onActivityResult(int requestCode,int resultCode, Intent data)
{
if(requestCode==PROJECT_REQUEST_CODE) {
if(data!=null&&data.hasExtra("text")) {
c = data.getStringExtra("text");
txt1.setText(c);
viewImage.setImageBitmap(Global.img); //image can be returned
}
}
else if (requestCode==CAMERA_REQUEST_CODE)
{
}
}
b.setOnClickListener(new View.OnClickListener() { // back to Claims.java
public void onClick(View arg0) {
Intent returnIntent = new Intent();
a = "Project";
text = txt.getText().toString(); // amount
returnIntent.putExtra("text", text);
returnIntent.putExtra("a", a);
final int k1 = getIntent().getExtras().getInt("k");
returnIntent.putExtra("k1", k1);
returnIntent.putExtra("c",c);
setResult(Activity.RESULT_OK, returnIntent);
finish();
}
});
Claims.java
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case 0:
result = data.getStringExtra("text");
name = data.getStringExtra("a");
description=data.getStringExtra("c");
if (Global.img != null) {
v.setImageBitmap(Global.img); //image can shown here
}
c.setText(" " + name + "------" + "RM " + result);
break;
}
}
c.setOnClickListener(new View.OnClickListener() { //pass image to EditClaims.java
#Override
public void onClick(View v) {
if ((name != null && name.trim().length() > 0) && (result != null && result.trim().length() > 0)) {
Toast.makeText(getActivity().getApplicationContext(), "not null", Toast.LENGTH_LONG).show();
Global.img=null;
Intent intent = new Intent(getActivity(), EditClaims.class);
v.setDrawingCacheEnabled(true);
v.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
v.buildDrawingCache(true);
intent.putExtra("name", name);
intent.putExtra("result", result);
intent.putExtra("description", description);
if (v.getDrawingCache() != null) {
Bitmap bitmap = Bitmap.createBitmap(v.getDrawingCache());
if (bitmap == null) {
Log.e("TAG", "getDrawingCache() == null");
}
Global.img = bitmap;
startActivity(intent);
}
}
else {
Toast.makeText(getActivity().getApplicationContext(), "null", Toast.LENGTH_LONG).show();
}
}
} );
EditClaims.java
viewImage.setImageBitmap(Global.img);
Global.java
public class Global {
static Bitmap img;
}
But what I get in viewImage is (" " + name + "------" + "RM " + result) which is get from the c.setText. Can someone help me to figure out the problem?
Activity Flow: ImageFitScreen----->Back to project1----->Back to Claims----->Claims intent to EditClaims
Screen shot of Claims
Note that the image beside Amount is return from Project1. Since c.setText is not null, it can intent to EditClaims.java.
It works like charm, but only for captured image.
Now I try with the image from gallery
When I click c, it shows me this. It didn't intent to EditClaims.java
The problem is with the OnClickListener you're setting on c. That listener has a method public void onClick(View v), in which you're confusing your v variables.
Judging from the onActivityResult() method, you have a class member ImageView named v. But, within the onClick() method, an unqualified v is going to be the View v passed into the method, not the class member v. The View v passed into the onClick() method of an OnClickListener is the View that is being clicked, so this explains why you're seeing the content of c in the next Activity.
The simplest solution would be to change the parameter variable of the onClick() method to a different name. For example:
public void onClick(View view)

Categories