1

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

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

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

2 回答 2

0

覆盖onActivityResult方法:

onActivityResult(int reqCode, int respCode, Intent extra)
{
   if(reqCode == CAMERA_REQUEST && respCode == RESULT_OK)
   {
      //Photo has been taken, redirect the user.
   }
}
于 2013-03-12T10:02:53.087 回答
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");
于 2013-03-12T10:10:00.293 回答