我的应用程序出了问题,我已经创建了相机功能,但是我需要在获取图像后,页面应该重定向到另一个具有该图像的活动。
我已将以下代码用于相机功能:
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
答案 0 :(得分:0)
覆盖onActivityResult
方法:
onActivityResult(int reqCode, int respCode, Intent extra)
{
if(reqCode == CAMERA_REQUEST && respCode == RESULT_OK)
{
//Photo has been taken, redirect the user.
}
}
答案 1 :(得分:0)
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
switch (requestCode) {
case PICK_FROM_CAMERA:
if (resultCode == Activity.RESULT_OK) {
Bitmap bitmapImage = (Bitmap) intent.getExtras().get("data");
//Redirectin to your second activty passing Bitmap Object
Intent intent = new Intent(getApplicationContext(),
SecondActivity.class);
intent.putExtra("bitmap", bitmapImage);
startActivity(intent);
}
}
在SecondActivity.java中
检索类似
的位图Bitmap bitImage=getIntent().getParcelableExtra("bitmap");