I am using Tab Activity as a main Activity in which it has 4 tabs. One tab is Activity Group which has three buttons. Each button is one activity. I am using camera in one of those activity. I know its working because i have checked in the memory card the image get saved, but it doesn't calling the Onactivityresult() method.
This is to display the ContentView
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.enter_expenses, null);
this.setContentView(viewToLoad);
This code is used to take the image
dbimgguid = UUID.randomUUID();
imagename =dbimgguid.toString();
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
photo = new File(Environment.getExternalStorageDirectory(), "Expenses"+imagename+".jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(photo));
imageurl = Uri.fromFile(photo);
startActivityForResult(intent, CAMERA_RECEIPTREQUEST);
This is onactivity result
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
System.out.println(requestCode);
System.out.println(resultCode);
switch(requestCode)
{
case CAMERA_RECEIPTREQUEST:
if(resultCode== Activity.RESULT_OK)
{
//Toast.makeText(this, "Receipt Image Saved", Toast.LENGTH_SHORT).show();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;
//ImageView jpgView = (ImageView)findViewById(R.id.imageView1);
Bitmap receipt = BitmapFactory.decodeFile(photo.toString(),options);
String image = "Expenses"+imagename+".jpg";
Intent imagepass = new Intent(ExpensesActivity.this,ReviewReceiptImage.class);
imagepass.putExtra("receipt", receipt);
imagepass.putExtra("imagename", image);
startActivityForResult(imagepass, CAMERA_CONFIRMRECEIPT);
Toast.makeText(this, "Receipt Image Saved", Toast.LENGTH_SHORT).show();
}
case CAMERA_CONFIRMRECEIPT:
Toast.makeText(this, "Receipt Image Saved", Toast.LENGTH_SHORT).show();
if(resultCode == CAMERA_CONFIRMRECEIPT)
{
take_receipt.setEnabled(false);
take_receipt.setVisibility(View.GONE);
show_receipt.setEnabled(true);
show_receipt.setVisibility(View.VISIBLE);
}
break;
}
}
Thanks for your help guys
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…