Program will not switch to activity on my phone
public class TestCamera extends Activity implements SurfaceHolder.Callback, View.OnClickListener {
...
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
// TODO Auto-generated method stub
picture = data;
}
};
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER)) {
mCamera.takePicture(null, null,开发者_StackOverflow mPictureCallback);
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onClick(View view) {
switch(view.getId()) {
case R.id.camera:
picture_intent = new Intent(this, PictureViewer.class);
picture_intent.putExtra("picture", picture);
mCamera.startPreview();
startActivity(picture_intent);
}
}
In the emulator, the program behaves like it should. However, when I put this application on my phone (Nexus one), it doesn't switch to the new Activity when I touch the screen after I take a picture. If I touch the screen without taking a picture, it switches to the new activity.
I can't figure out why my phone won't switch to the new Activity after taking a picture.
It might be easier to add a new member to your PictureViewer class and assign the byte[] to that instead of trying to use it as an extra.
I notice you are including the byte[] as an extra for your new Intent. It is possible that the image captured by the Nexus One has a large memory footprint. Passing a large object as an extra could cause the behavior you are describing. Have you tried connecting your Nexus One to Eclipse and following the execution path with the debugger? You can also analyze the memory through Eclipse.
精彩评论