matan12128:
//グローバル変数
static final int CAMERA_REQUEST = 1;
ImageView imageview;
Bitmap bitmap;
//で作成します。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//テイク参照
imageview = findViewById(R.id.image_view);
// onclickのリスナーとの意図:
Button take_photo_btn = findViewById(R.id.photo_btn);
take_photo_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAMERA_REQUEST);
}
});
//これは結果のための活動です。
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST && requestCode == RESULT_OK) {
Bundle extras = data.getExtras();
bitmap = (Bitmap) extras.get("image");
imageview.setImageBitmap(bitmap);
}
}
}
私は写真を撮る後、私は画像表示いただきました中でそれを参照してくださいdidntの問題です?
matan12128:
[OK]を私は問題を発見しました
if (requestCode == CAMERA_REQUEST && requestCode == RESULT_OK
私はこれを行うためにNEES:
もし(requestCode == CAMERA_REQUEST &&のresultCode == RESULT_OK)