ContentObserver new onChange public API crash on android 10 (api 29)

93 Views Asked by At

In ContentObserver, there is a new public API overload "onChange(boolean, Uri, int)" that delivers a int flags argument. in android 10 (api 29) only, if i call super.onChange(selfChange, uri, flags) app crashed with this error

Uncaught remote exception!  (Exceptions are not yet supported across processes.)
java.lang.NoSuchMethodError: No super method onChange(ZLandroid/net/Uri;I)V in class Landroid/database/ContentObserver;
 or its super classes (declaration of 'android.database.ContentObserver' appears in /system/framework/framework.jar)

so i added this

if (Build.VERSION.SDK_INT != Build.VERSION_CODES.Q) {
     super.onChange(selfChange, uri, flags)
}

and solved my problem of course flags value for pre api 30 is always 0 i have many questions why there is no @TargetApi for this method or any warning? am i doing something wrong at all? how should developer know this method "super.onChange(selfChange, uri, flags)" is not work on pre api 30 and crash on api 29?

0

There are 0 best solutions below