ScreenShotDemo
ScreenShotDemo copied to clipboard
兼容Android10,11之后onChange()不回调问题
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 ); }
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 值的差异吗?
Android 11 Api 30 (!cursor.moveToFirst()) reture了
Android 11 Api 30 (!cursor.moveToFirst()) reture了
确实是这样,后来你怎么处理的