Detected problems with API 弹窗

This problem is reflected prohibit wrong android P reported, the following codes detected by the bypass

//在app初始化时调用即可
public class MyApplication extends Application {
 
    public JoyApplication() {
    }
 
    @Override
    public void onCreate() {
        super.onCreate();
        disableAPIDialog();
    } 
     /**
      * 反射 禁止弹窗
     */
    private void disableAPIDialog(){
       if (Build.VERSION.SDK_INT < 28)return;
       try {
            Class clazz = Class.forName("android.app.ActivityThread");
         Method currentActivityThread = clazz.getDeclaredMethod("currentActivityThread");
         currentActivityThread.setAccessible(true);
         Object activityThread = currentActivityThread.invoke(null);
         Field mHiddenApiWarningShown = clazz.getDeclaredField("mHiddenApiWarningShown");
         mHiddenApiWarningShown.setAccessible(true);
         mHiddenApiWarningShown.setBoolean(activityThread, true);
       } catch (Exception e) {
           e.printStackTrace();
       }
   }
 
}

 

Guess you like

Origin blog.csdn.net/dubo_csdn/article/details/90901559