我试图用相机Intent拍照,然后立即将活动背景设置为该图像。
@SuppressWarnings("deprecation")
public void TakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = SavePicture();
} catch (IOException ex) {
return;
}
if (photoFile != null) {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photoFile));
startActivityForResult(takePictureIntent, 1);
RelativeLayout rl = (RelativeLayout)findViewById(R.id.activity_layout);
Bitmap bitmap = BitmapFactory.decodeFile(photoFile.getAbsolutePath());
Drawable dr = new BitmapDrawable(bitmap);
rl.setBackgroundDrawable(dr);
}
}
}
只看我的代码,它看起来不正确。来自班级的过多转化。
我将如何做到这一点?