Android 调用系统照相程序并显示 各位高手帮我看看为什么出现这样的问题 50
publicclassXinghuoActivityextendsActivity{ImageViewimage;@OverridepublicvoidonCreate(...
public class XinghuoActivity extends Activity {
ImageView image;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if (resultCode == Activity.RESULT_OK) {
// 拍照Activity保存图像数据的key是data,返回的数据类型是Bitmap对象
Bitmap cameraBitmap = (Bitmap) data.getExtras().get("/sdcard/rtest.jpg");
// 在ImageView组件中显示拍摄的照片
image.setImageBitmap(cameraBitmap);
}
} super.onActivityResult(requestCode, resultCode, data);
}
}
threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
Uncaught handler: thread main exiting due to uncaught exception
08-18 11:17:46.385: DEBUG/StatusBar(583): updateResources
08-18 11:17:46.474: ERROR/AndroidRuntime(801): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { action=inline-data (has extras) }} to activity {cn.ceshi/cn.ceshi.XinghuoActivity}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3005)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3047) 展开
ImageView image;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if (resultCode == Activity.RESULT_OK) {
// 拍照Activity保存图像数据的key是data,返回的数据类型是Bitmap对象
Bitmap cameraBitmap = (Bitmap) data.getExtras().get("/sdcard/rtest.jpg");
// 在ImageView组件中显示拍摄的照片
image.setImageBitmap(cameraBitmap);
}
} super.onActivityResult(requestCode, resultCode, data);
}
}
threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
Uncaught handler: thread main exiting due to uncaught exception
08-18 11:17:46.385: DEBUG/StatusBar(583): updateResources
08-18 11:17:46.474: ERROR/AndroidRuntime(801): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { action=inline-data (has extras) }} to activity {cn.ceshi/cn.ceshi.XinghuoActivity}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3005)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3047) 展开
4个回答
深圳市容大彩晶科技有限公司
2024-11-15 广告
2024-11-15 广告
广告机代理优选容大彩晶,深圳市容大彩晶科技有限公司自2007年成立伊始,一直专注于液晶商用显示产品的技术研发及产品服务。公司依托具有自主研发能力、创新高效的技术团队,打造出行业优质商用液晶显示设备。容大彩晶产品涵盖商用液晶显示、多媒体广告机...
点击进入详情页
本回答由深圳市容大彩晶科技有限公司提供
展开全部
z这样贴个图 神也帮不了你。给出log把
还有调用照相机的权限赋予了没有啊
还有调用照相机的权限赋予了没有啊
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把错误贴出来,大家一起看看呀!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询