从相机拍摄图像并重定向到特定页面

时间:2013-03-12 09:54:50

标签: android android-intent image-capture

我的应用程序出了问题,我已经创建了相机功能,但是我需要在获取图像后,页面应该重定向到另一个具有该图像的活动。

我已将以下代码用于相机功能:

@Override
public void onClick(View v) {
    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
    startActivityForResult(cameraIntent, CAMERA_REQUEST); 
}

2 个答案:

答案 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");