开发者社区> 问答> 正文

如何使用Android 3.5在文本活动中的batmap中获取图像uri?

我是一个新的android开发人员,我将开发高级照片编辑器,我想从一个活动中获取图像URI,并在下一个活动中以batmap的形式获取此uri。

错误:

11-29 11:53:26.893 31513-31513 / com.burhanrashid52.photoeditor E / AndroidRuntime:致命例外:主进程:com.burhanrashid52.photoeditor,PID:31513 java.lang.RuntimeException:无法启动活动ComponentInfo {com。 burhanrashid52.photoeditor / com.burhanrashid52.photoeditor.EraserActivity}:java.lang.NullPointerException:尝试对android.app.ActivityThread.performLaunchActivity()上的空对象引用调用虚拟方法'int android.graphics.Bitmap.getHeight()' android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2754)的ActivityThread.java:2689)android.app.ActivityThread $ H.handleMessage(ActivityThread。)的android.app.ActivityThread.access $ 900(ActivityThread.java:177) java:1448)在android.os.Handler.dispatchMessage(Handler.java:102)在android.os.Looper.loop(Looper.java:145)在android.app.ActivityThread.main(ActivityThread.java:5938)在java.lang.reflect.Method.invoke(本机方法)在java.lang com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1400)的com.android.internal.os.ZygoteInit.main(ZygoteInit.java)的.reflect.Method.invoke(Method.java:372) :1195)原因:java.lang.NullPointerException:尝试在com.burhanrashid52.photoeditor.EraserActivity.onCreate(EraserActivity.java:107)上的空对象引用上调用虚拟方法'int android.graphics.Bitmap.getHeight()'。 )android.app.Activity.performCreate(Activity.java:6288)在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)android.app.ActivityThread.main(ActivityThread.java:5938)处的loop(Looper.java:145)java.lang.reflect.Method.invoke(Method。 java:372)在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1400)在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)造成原因:java.lang .NullPointerException:尝试在com.burhanrashid52.photoeditor.EraserActivity.onCreate(EraserActivity.java:107)上的android.app.Activity.performCreate的null对象引用上调用虚拟方法'int android.graphics.Bitmap.getHeight()' (Activity.java:6288)位于android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)android.app.ActivityThread.main(ActivityThread.java:5938)处的loop(Looper.java:145)java.lang.reflect.Method.invoke(Method。 java:372)在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1400)在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)造成原因:java.lang .NullPointerException:尝试在com.burhanrashid52.photoeditor.EraserActivity.onCreate(EraserActivity.java:107)上的android.app.Activity.performCreate的null对象引用上调用虚拟方法'int android.graphics.Bitmap.getHeight()' (Activity.java:6288)位于android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)com.android.internal.os.ZygoteInit $的java.lang.reflect.Method.invoke(Method.java:372)的main(ActivityThread.java:5938) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)上的MethodAndArgsCaller.run(ZygoteInit.java:1400)原因:java.lang.NullPointerException:尝试调用虚拟方法'int android.graphics.Bitmap .getHeight()在com.burhanrashid52.photoeditor.EraserActivity.onCreate(EraserActivity.java:107)上的android.app.Activity.performCreate(Activity.java:6288)处为空对象引用,位于android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1119)com.android.internal.os.ZygoteInit $的java.lang.reflect.Method.invoke(Method.java:372)的main(ActivityThread.java:5938) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)上的MethodAndArgsCaller.run(ZygoteInit.java:1400)原因:java.lang.NullPointerException:尝试调用虚拟方法'int android.graphics.Bitmap .getHeight()在com.burhanrashid52.photoeditor.EraserActivity.onCreate(EraserActivity.java:107)上的android.app.Activity.performCreate(Activity.java:6288)处为空对象引用,位于android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1119)由com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)引起的com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1400)处的invoke(Method.java:372) :java.lang.NullPointerException:尝试在android.app的com.burhanrashid52.photoeditor.EraserActivity.onCreate(EraserActivity.java:107)上的空对象引用上调用虚拟方法'int android.graphics.Bitmap.getHeight()' android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)上的.Activity.performCreate(Activity.java:6288)由com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)引起的com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1400)处的invoke(Method.java:372) :java.lang.NullPointerException:尝试在android.app的com.burhanrashid52.photoeditor.EraserActivity.onCreate(EraserActivity.java:107)上的空对象引用上调用虚拟方法'int android.graphics.Bitmap.getHeight()' android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)上的.Activity.performCreate(Activity.java:6288)尝试在android.app.Activity.performCreate(Activity.com)上的com.burhanrashid52.photoeditor.EraserActivity.onCreate(EraserActivity.java:107)的null对象引用上调用虚拟方法'int android.graphics.Bitmap.getHeight()'。 java:6288)在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)尝试在android.app.Activity.performCreate(Activity.com)上的com.burhanrashid52.photoeditor.EraserActivity.onCreate(EraserActivity.java:107)的null对象引用上调用虚拟方法'int android.graphics.Bitmap.getHeight()'。 java:6288)在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)

首次活动代码

Uri ur;
ur = Uri.parse(String.valueOf(mPhotoEditorView));

Intent intent = new Intent(EditImageActivity.this, EraserActivity.class);
//intent.putExtra("BitmapImage",convertImageToByte(ur));
intent.putExtra("key", mPhotoEditorView.toString());
Toast.makeText(getApplicationContext(), "hello baby", 
Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "hello baby i am there 
",Toast.LENGTH_LONG).show();
startActivity(intent);

下一个活动代码

Intent intent = getIntent();
String image_path= intent.getStringExtra("key");
Uri fileUri = Uri.parse(image_path);
// imageview.setImageURI(fileUri);

InputStream in = null;
try {
in = getContentResolver().openInputStream(fileUri);
} catch (FileNotFoundException e) {
   e.printStackTrace();
}
mBitmap = BitmapFactory.decodeStream(in);

展开
收起
垚tutu 2019-11-29 23:12:07 1043 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载