我想捕捉圖像&將它保存到SD卡。現在它工作正常。 我的問題是1)拍攝後OK and Cancel
按鈕是avialble。當我點擊確定只需要將圖像保存到SD卡。onActivityResult不適用於Camera -Tab ActivityGrup
2)它不來onActivityResult
方法。我在ActivityGroup
課內寫過我的onActivityResult
。
此代碼爲當相機按鈕用戶點擊,它就會打開cameara &保存它
//Camera
Button btnCamera =(Button)findViewById(R.id.btnCamera);
btnCamera.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
selectedImagePath = Environment.getExternalStorageDirectory()+"/"+retailerCode+"-"+count+".jpg";
imgName =retailerCode+"-"+count+".jpg";
count++;
File file = new File(selectedImagePath);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Bundle b = new Bundle();
b.putString("Activity", "RetailerOrderSActivity");
b.putString("RetailerName", seletctedRetailer);
b.putString("RetailerCode", retailerCode);
intent.putExtras(b);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, CAMERA_PIC_REQUEST);
onPhotoTaken();
}
});
protected void onPhotoTaken() {
_taken = true;
DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(CameraMainActivity.this);
dbAdapter.openDataBase();
boolean status = dbAdapter.saveImageInfo(retailerCode,strExecutive,strBusinessUnit,strTerritoryCode,imgName,visitNumber);
if(status) {
Toast.makeText(SalesActivityGroup.group.getApplicationContext(), "Image has been saved successfully" , Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(SalesActivityGroup.group.getApplicationContext(), "Image has not been saved successfully" , Toast.LENGTH_SHORT).show();
}
dbAdapter.close();
lstCaptures = getAllImage(imgDateVal.getText().toString());
imageViewTable.removeAllViews();
loadTableLayout();
}
這是代碼的ActivityGroup
public class SalesActivityGroup extends ActivityGroup {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
System.out.println("===REQUEST=====" +requestCode);
System.out.println("==resultCode==" +resultCode); } }
其實我需要調用onPhotoTaken
從onActivityResult
。根據目前我的代碼,如果用戶也點擊取消,它將信息保存到數據庫。圖像不捕獲..
這是我的應用程序圖像:
這是後捕獲圖像按鈕顯示:
請人理清這個問題..
在此先感謝
是,嘗試[這](http://stackoverflow.com/a/6679665/940096)之一。 – Praveenkumar 2012-04-17 12:20:47