华为手机头像上传操作, 裁剪点存储--进入裁剪后--点确定, 就直接报错退出程序了,其他机型测都是成功的,求大神指教
报错代码
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// try {
// tvNickName.setText(URLDecoder.decode(URLDecoder.decode(getConfig()
// .getUserInfo().getUserName(), "utf-8"), "utf-8"));
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
switch (requestCode) {
case Constant.REQUEST_CAMERA_TAKE_PIC:
// 拍照
if (RESULT_OK == resultCode) {
startPhotoZoom(photoUri);
}
break;
case Constant.REQUEST_SELECT_PIC_SINGLE:
if (RESULT_OK == resultCode) {// 从相册选取
Uri uri = data.getData();
if (uri != null) {
// 大坑 4.4之后 相册选取图片返回Uri跟以前的不太一样了
//content://media/external/images/media/87540
String path = SystemUtils.getPath(this, data.getData());
Logger.d(path + "");
startPhotoZoom(Uri.fromFile(new File(path)));
}
}
break;
case CUT_PHOTO_REQUEST_CODE:
// 裁剪返回
if (resultCode == RESULT_OK && null != data) {
//postHeadIcon(getConfig().getUserInfo().getUserId(), drr);
//String PicturePath = data.getStringExtra(MediaStore.EXTRA_OUTPUT);
Logger.d(mFileName +"裁剪返回的类型名" + mProtraitPath);
uploadNewPhoto(getConfig().getUserName(), mFileName, mProtraitPath);
}
break;
default:
break;
}
}
3.报错日志
Caused by: java.lang.NullPointerException
at java.io.File.fixSlashes(File.java:185)
at java.io.File.<init>(File.java:134)
at com.ht.alphagu.activity.UserInfoActivity.copressImage(UserInfoActivity.java:462)
at com.ht.alphagu.activity.UserInfoActivity.uploadNewPhoto(UserInfoActivity.java:261)
at com.ht.alphagu.activity.UserInfoActivity.onActivityResult(UserInfoActivity.java:247)
at android.app.Activity.dispatchActivityResult(Activity.java:5554)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3548)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2962)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3004)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2318)
at android.app.ActivityThread.access$1100(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5336)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:873)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)
at dalvik.system.NativeStart.main(Native Method)
获取裁剪后图片的路径用绝对路径试试,如:
File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/YourFolder");