gpt4 book ai didi

java - 结果传递失败 ResultInfo{who=null, request=2, result=0, data=null} camera

转载 作者:行者123 更新时间:2023-11-29 10:01:30 24 4
gpt4 key购买 nike

这是相机代码

   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)]

最佳答案

如果您在 Kotlin 上遇到错误,只需将 data Intent 标记为 @nullable 通过添加 ?在 Intent 类型声明之后。所以它应该是这样的:

data: Intent?.

关于java - 结果传递失败 ResultInfo{who=null, request=2, result=0, data=null} camera,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25565568/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com