私はAndroidを初めて使用し、デフォルトのAndroidカメラを使用するアプリケーションで撮影した画像を保存するためにコードの一部を作成しようとしています。カメラを終了したら、別のアクティビティで画像を表示したい。今のところ、保存しないと、カメラモードを終了すると画像が表示されます。しかし、私もそれを保存しようとすると、カメラはまったく終了せず、「OK」ボタンが応答しません。写真を撮ってメールに添付し、GPS位置データと一緒に送信するアプリを作ろうとしています。そのため、スイッチケースの「メッセージ送信」部分があります。
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.Picture:
File file = new File(Environment.getExternalStorageDirectory().getPath() + "/My Images/" + "bhe_app" + ".jpg");
Uri imageUri = Uri.fromFile(file);
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(i, cameraData);
break;
case R.id.SendMessage: //Sending message part
EditTextToString();
EmailIntent = new Intent(android.content.Intent.ACTION_SEND);
EmailIntent.putExtra(Intent.EXTRA_EMAIL,
new String[] { "myEmail@gmail.com" });
EmailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
MessageToBeReceived);
EmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "@"+Lattitude_data +"," +Longitude_data);
// EmailIntent.setType("message/rfc822");
EmailIntent.setType("image/jpeg");
// EmailIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
startActivity(Intent.createChooser(EmailIntent,
"Choose an Email client :"));
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
bmp = (Bitmap) extras.get("data");
iv.setImageBitmap(bmp);
//iv is an image view in an activity where I display the image taken.
//bmp is defined as being Bitmap.
// final static int cameraData =0
}
}