在$ P $图像采集应用程序崩溃pssing后退按钮
问题描述:
public class MainActivity extends Activity {
private static final int CAMERA_PIC_REQUEST = 2500;
Button Report_help;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Report_help=(Button)findViewById(R.id.report_help);
Report_help.setOnClickListener(new OnClickListener()
{
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST) {
Bitmap image = (Bitmap) data.getExtras().get("data");
ImageView imageview = (ImageView) findViewById(R.id.display_image);
imageview.setImageBitmap(image);
}
}
}
该应用程序捕获图像,并显示在imageview.But问题是我捕捉到的图像和preSS后退按钮应用crashes.I不知道为什么会这样以后?请任何人的帮助。
This app captures the image and displays in the imageview.But the problem is after I capture the image and press the back button app crashes.I don't know why is this so? Please anyone help.
答
我认为当你preSS后退按钮
I think when you press back button
Bitmap image = (Bitmap) data.getExtras().get("data");
在的onActivityResult导致空指针异常错误,请搭上这一个。
in onActivityResult cause the Null pointer exception error, please catch this one.