我使用 Tab 活动作为主要活动, 它有 4 个制表符。 一个制表符是活动组, 有 3 个按钮 。 每个按钮都是一个活动 。 我在其中一项活动中使用相机 。 我知道它的工作, 因为我在存储卡中检查了保存的图像, 但是它没有使用 OnactutionAgress () 方法 。
这是要显示内容View
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.enter_expenses, null);
this.setContentView(viewToLoad);
此代码用于拍摄图像
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);
这是活动结果
@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;
}
}
谢谢你的帮忙 伙计们