android 开发 拍照的时候取消就会错误
代码抄网上,当用户正常拍照的时候没问题,但如果拍照的时候点返回就会进程错误。。。。求助oncreate的:btn1.setOnClickListener(newOnCli...
代码抄网上,当用户正常拍照的时候没问题,但如果拍照的时候点返回就会进程错误。。。。求助
oncreate的:
btn1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
try {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent,RESULT_TAKE_PHOTO);
} catch (Exception e) {
Log.v(logTag, e.getMessage());
}
}
});
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch(requestCode){
case RESULT_TAKE_PHOTO:
try {
super.onActivityResult(requestCode, resultCode, data);
Bundle extras = data.getExtras();
Bitmap b=null;
if(extras!=null){b = (Bitmap) extras.get("data");
if(b!=null)img1.setImageBitmap(b);
}
break;
}
} 展开
oncreate的:
btn1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
try {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent,RESULT_TAKE_PHOTO);
} catch (Exception e) {
Log.v(logTag, e.getMessage());
}
}
});
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch(requestCode){
case RESULT_TAKE_PHOTO:
try {
super.onActivityResult(requestCode, resultCode, data);
Bundle extras = data.getExtras();
Bitmap b=null;
if(extras!=null){b = (Bitmap) extras.get("data");
if(b!=null)img1.setImageBitmap(b);
}
break;
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询