public class FulfillPhotoTaskActivity extends Activity implements OnClickListener {
ImageView iv;
Uri outputFileUri;
Button takePhoto;
Button uploadPhoto;
Bitmap bmp;
Intent cameraIntent;
File file;
final static int cameraData = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fulfill_photo_task);
initialize();
}
private void initialize() {
iv = (ImageView) findViewById(R.id.imageView1);
takePhoto = (Button) findViewById(R.id.takePhoto);
takePhoto.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_fulfill_photo_task, menu);
return true;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
File root = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmp");
String folder = root.toString();
file = new File(folder, "fileName" + ".jpg");
Uri outputFileUri = Uri.fromFile(file);
cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(cameraIntent, cameraData);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == RESULT_OK)
{
Bundle extras = data.getExtras();
bmp = (Bitmap) extras.get("data");
iv.setImageBitmap(bmp);
}
}
}
エミュレーターでこのプログラムを実行すると、写真を撮り、撮影した写真を使用するチェックを押した後、何もしませんImageView
。
このコードにはバグがありますか?