惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
G
Google Developers Blog
人人都是产品经理
人人都是产品经理
U
Unit 42
爱范儿
爱范儿
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
B
Blog RSS Feed
The Cloudflare Blog
D
Docker
A
About on SuperTechFans
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Y
Y Combinator Blog
月光博客
月光博客
云风的 BLOG
云风的 BLOG
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
博客园_首页
Stack Overflow Blog
Stack Overflow Blog

博客园 - 清炒白菜

Android的匿名Handler类引起的内存泄露 计算2个经纬度之间的距离 用bcp导入DateTime类型的数据 Linux下提示“omitting directory”错误的解决办法 Android的"返回“功能 EditText获得焦点后,如何关闭软键盘 获取当前Activity的Root View 用代码动态设置ImageView的align布局 Android中Sqlite数据库多线程并发问题 [转]Java的数组(Array)、Vector、ArrayList、HashMap的异同 HTML中element.style取值问题 用bcp导入大量数据(代替INSERT) ajax跨域访问问题 又一款分布式版本控制工具Mercurial bcp导入导出数据发生异常解决方案 - 清炒白菜 - 博客园 导出Google Reader中加星的内容项 - 清炒白菜 - 博客园 在win下使用GIT dotNet 自带线程池与HTTP访问的若干疑问 解决"the database principal owns a schema in the database and cannot be dropped"问题
Unable to resume activity : android.database.StaleDataExc...
清炒白菜 · 2013-05-17 · via 博客园 - 清炒白菜

2013-05-17 19:21  清炒白菜  阅读(4294)  评论()    收藏  举报

一般用Cursor后, 就立即close()了,但是在用managedQuery的时候, 却不能主动调用close()方法, 否则在Android 4.0+的系统上, 会发生崩溃

google的文档是这么写的

Warning: Do not call close() on a cursor obtained using this method, because the activity will do that for you at the appropriate time. However, if you call stopManagingCursor(Cursor) on a cursor from a managed query, the system will not automatically close the cursor and, in that case, you must call close().

也有人说用下面的方法可以避免这个问题

这个问题其实很简单  估计大家在查询数据库的时候用的是这个函数  
viedoCursor = context.managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoColumns,null, null, null);
只要换成这样就可以了:
ContentResolver cr = context.getContentResolver();
viedoCursor = cr.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoColumns,null, null, null);
我也是无意间发现有着两种写法的 然后试了一下问题就解决了

参考:http://stackoverflow.com/questions/9696868/unable-to-resume-activity-error

http://changyy.pixnet.net/blog/post/31238721-android-%E9%96%8B%E7%99%BC%E7%AD%86%E8%A8%98---unable-to-resume-activity-%3A-android.d