我正在製作一個程序,拍攝一張照片然後顯示它的縮略圖。 使用模擬器時一切順利,放棄按鈕刪除照片。 但是,在真實設備上,相機意圖將圖像保存在imageUri變量中,而另一個名爲像是我打開相機並單獨拍攝照片那樣命名的圖像。Android相機意圖創建兩個文件
private static final int CAMERA_PIC_REQUEST = 1337;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.camera);
//start camera
values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, "New Picture");
values.put(MediaStore.Images.Media.DESCRIPTION,"From your Camera");
imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
image = (ImageView) findViewById(R.id.ImageView01);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, CAMERA_PIC_REQUEST);
//save the image buttons
Button save = (Button) findViewById(R.id.Button01);
Button close = (Button) findViewById(R.id.Button02);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK) {
try{
thumbnail = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
image.setImageBitmap(thumbnail);
}
catch(Exception e){
e.printStackTrace();
}
}
else{
finish();
}
}
public void myClickHandler(View view) {
switch (view.getId()) {
case R.id.Button01:
finish();
break;
case R.id.Button02:
dicard();
}
}
private void dicard(){
getContentResolver().delete(imageUri, null, null);
finish();
}
我測試了HTC Incredible上的程序,它工作得很好。這是LG ALLY手機的一個已知問題嗎? – 2010-12-25 07:24:11