ScreenShotDemo icon indicating copy to clipboard operation
ScreenShotDemo copied to clipboard

兼容Android10,11之后onChange()不回调问题

Open GodLike1113 opened this issue 3 years ago • 3 comments

if (Build.VERSION.SDK_INT < 29) { //Android 9及以下版本,否则不会回调onChange() // 注册内容观察者 mContext.getContentResolver().registerContentObserver( MediaStore.Images.Media.INTERNAL_CONTENT_URI, false, mInternalObserver ); mContext.getContentResolver().registerContentObserver( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, mExternalObserver ); } else { //Android 10,11以上版本 // 注册内容观察者 mContext.getContentResolver().registerContentObserver( MediaStore.Images.Media.INTERNAL_CONTENT_URI, true, mInternalObserver ); mContext.getContentResolver().registerContentObserver( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, true, mExternalObserver ); }

GodLike1113 avatar Dec 31 '20 08:12 GodLike1113

notifyForDescendants When false, the observer will be notified * whenever a change occurs to the exact URI specified by * uri or to one of the URI's ancestors in the path * hierarchy. When true, the observer will also be notified * whenever a change occurs to the URI's descendants in the path * hierarchy.

这里的变化和原代码只是一个 Boolean 值的差异吗?

13120241790 avatar Mar 29 '21 07:03 13120241790

Android 11 Api 30 (!cursor.moveToFirst()) reture了

MhuiHugh avatar Jan 24 '24 06:01 MhuiHugh

Android 11 Api 30 (!cursor.moveToFirst()) reture了

确实是这样,后来你怎么处理的

wanglijun93 avatar Feb 22 '24 09:02 wanglijun93