无法传送结果ResultInfo {who = null,request = 2,result = 0,data = null}摄像机 [英] Failure delivering result ResultInfo{who=null, request=2, result=0, data=null} camera

查看:70
本文介绍了无法传送结果ResultInfo {who = null,request = 2,result = 0,data = null}摄像机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是相机代码

   private void selectImage(){

 final  int Camera_CPTURE = 1;

try {
    Intent capture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(capture,Camera_CPTURE);
}catch (ActivityNotFoundException e)
{
    String error ="opps ur devices doesn't support capturing";
    Toast toast = Toast.makeText(this,error,Toast.LENGTH_SHORT);
    toast.show();
}
}




protected void onActivityResult(int requestCode, int resultCode, Intent data) {


    if (resultCode == RESULT_OK) {
        picUri = data.getData();
        performCrop();  }
    else if(requestCode == PIC_CROP)
    {
        Bundle extra = data.getExtras();
        Bitmap thePic = extra.getParcelable("data");
        ImageView picView = (ImageView)findViewById(R.id.imageView);
        picView.setImageBitmap(thePic);
    }

    }

private void performCrop() {
    try {
       Intent cropIntent = new Intent("com.android.camera.action.CROP");
        cropIntent.setDataAndType(picUri,"image/*");
        cropIntent.putExtra("crop","true");
        cropIntent.putExtra("aspectX",1);
        cropIntent.putExtra("aspectY",1);
        cropIntent.putExtra("outputX",200);
        cropIntent.putExtra("outputY",200);
        cropIntent.putExtra("return-data",true);
        startActivityForResult(cropIntent,PIC_CROP);

    }catch (ActivityNotFoundException e)
    {
        String error ="opps ur devices doesn't support capturing";
        Toast toast = Toast.makeText(this,error,Toast.LENGTH_SHORT);
        toast.show();
    }
}





@Override
public void onClick(View view) {
    if(view.getId()==R.id.button){
        selectImage();

    }

}
}

日志在这里

[java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2, 

result=0, data=null} to activity 

{com.gurucharan.studentdatabase/com.gurucharan.studentdatabase.MyActivity}:                

java.lang.NullPointerException

at android.app.ActivityThread.deliverResults(ActivityThread.java:3007)

at android.app.ActivityThread.handleSendResult(ActivityThread.java:3050)

at android.app.ActivityThread.access$1100(ActivityThread.java:127)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1188)

at android.os.Handler.dispatchMessage(Handler.java:99)

at android.os.Looper.loop(Looper.java:137)

at android.app.ActivityThread.main(ActivityThread.java:4448)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:511)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)

at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.NullPointerException

at com.gurucharan.studentdatabase.MyActivity.onActivityResult(MyActivity.java:61)

at android.app.Activity.dispatchActivityResult(Activity.java:4649)

at android.app.ActivityThread.deliverResults(ActivityThread.java:3003)
 
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3050)
 
at android.app.ActivityThread.access$1100(ActivityThread.java:127)
 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1188)
 
at android.os.Handler.dispatchMessage(Handler.java:99)
 
at android.os.Looper.loop(Looper.java:137)
 
at android.app.ActivityThread.main(ActivityThread.java:4448)
 
at java.lang.reflect.Method.invokeNative(Native Method)
 
at java.lang.reflect.Method.invoke(Method.java:511)
 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
 
at dalvik.system.NativeStart.main(Native Method)

08-29 14:40:13.503    1819-2133/? E/JavaBinder﹕ !!! FAILED BINDER TRANSACTION !!!

08-29 14:40:13.503    1819-2133/? E/JavaBinder﹕ !!! FAILED BINDER TRANSACTION !!!

08-29 14:40:13.503    2053-2053/? E/JavaBinder﹕ !!! FAILED BINDER TRANSACTION !!!

08-29 14:40:14.274  10409-10409/? E/wpa_supplicant﹕ RX ctrl_iface - hexdump_ascii(len=11)]

推荐答案

if(requestCode==Camera_CPTURE && resultCode=RESULT_OK && data!=null)
    {

    }

这篇关于无法传送结果ResultInfo {who = null,request = 2,result = 0,data = null}摄像机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆