在$ P $图像采集应用程序崩溃pssing后退按钮 [英] image capture app crashes on pressing back button
本文介绍了在$ 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.
这篇关于在$ P $图像采集应用程序崩溃pssing后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文