Cause :android.content.res.Resources$NotFoundException: String resource ID #0x0
来源:互联网 发布:如何从网页提取数据 编辑:程序博客网 时间:2024/05/16 23:42
1.log 日志:
08-01 04:31:36.016: E/AndroidRuntime(3133): FATAL EXCEPTION: main08-01 04:31:36.016: E/AndroidRuntime(3133): Process: com.honeybee.selectcontactdemo, PID: 313308-01 04:31:36.016: E/AndroidRuntime(3133): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.honeybee.selectcontactdemo/com.honeybee.selectcontactdemo.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x02.原因:
Map<String, Object> map = new HashMap<String, Object>();Cursor dataCursor = resolver.query(uriData, new String[] {"mimetype", "data1" }, "contact_id=?",new String[] { contactId }, null);// 查询 contact id 对应的信息while (dataCursor.moveToNext()) {String mimetype = <span style="color:#ff0000;">dataCursor</span>.getString(0);String data = <span style="color:#ff0000;">dataCursor</span>.getString(1);if (mimetype.equals("vnd.android.cursor.item/phone_v2")) {map.put("phone", data);System.out.println("phone is:" + data);} else if (mimetype.equals("vnd.android.cursor.item/name")) {map.put("name", data);System.out.println("name is:" + data);}}list.add(map);dataCursor.close();
红色code缺失,导致调用的是当前activity的getString(0)方法,应该是传入参数0报的资源找不到错误,编译可以通过,运行会导致FC。
附加http://blog.csdn.net/jasper_success/article/details/7059108,网上搜到的导致此FC的常见原因如下,显然此例属于例外。
如果遇到这个问题,首先考虑以下原因:
你是否在setText()方法中设置了一个int型变量,比如setText(10)。
这样Android系统就会主动去资源文件当中寻找, 但是它不是一个资源文件ID, 所以就会报出这个bug。
解决办法:将int型业务数据,转换成String类型即可,比如setText(10+“”);
0 0
- Cause :android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- # android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0
- android.content.res.Resources$NotFoundException: Resource ID #0x0,错误
- android.content.res.Resources$NotFoundException: Resource ID #0x0
- android.content.res.Resources$NotFoundException: Resource ID #0x0
- Android中用application在两个activity中进行数据共享(2)
- 剑指Offer面试题16(Java版):反转链表
- MPLS VPN
- 编程之美:第三章 结构之法 3.10分层遍历二叉树
- maven的本地仓库 repository
- Cause :android.content.res.Resources$NotFoundException: String resource ID #0x0
- onCreate()过程中获取View的width和Height
- 利用cocos2d来发野菜部落的空雅强力弹棋
- 使用Spine软件为骨骼动画制作简单特效
- ubuntu 14.04 无线网卡驱动安装
- resin JVM内存设置简要
- app后端设计(4)-- 通讯的安全性
- hadoop参数配置详解
- 编程之美:第三章 结构之法 3.11程序改错