SHARE
TWEET

Untitled

a guest Jun 16th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. java.lang.NoSuchMethodError: No static method canDrawOverlays(Landroid/content/Context;)Z in class Landroid/provider/Settings; or its super classes (declaration of 'android.provider.Settings' appears in /system/framework/framework.jar)
  2.     at com.pack.MainActivity.checkDrawOverlayPermission(MainActivity.java:311)
  3.     at com.pack.MainActivity.onCreate(MainActivity.java:127)
  4.     at android.app.Activity.performCreate(Activity.java:6033)
  5.     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
  6.     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288)
  7.     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2397)
  8.     at android.app.ActivityThread.access$800(ActivityThread.java:151)
  9.     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1310)
  10.     at android.os.Handler.dispatchMessage(Handler.java:102)
  11.     at android.os.Looper.loop(Looper.java:135)
  12.     at android.app.ActivityThread.main(ActivityThread.java:5268)
  13.     at java.lang.reflect.Method.invoke(Native Method)
  14.     at java.lang.reflect.Method.invoke(Method.java:372)
  15.     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
  16.     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
  17.      
  18. /** code to post/handler request for permission */
  19.     public final static int REQUEST_CODE = 100; /*(see edit II)*/
  20.  
  21.     @SuppressLint("NewApi")
  22.     public void checkDrawOverlayPermission() {
  23.         /** check if we already  have permission to draw over other apps */
  24.         if (!Settings.canDrawOverlays(this)) {
  25.             /** if not construct intent to request permission */
  26.             Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
  27.                     Uri.parse("package:" + getPackageName()));
  28.             /** request permission via start activity for result */
  29.             startActivityForResult(intent, REQUEST_CODE);
  30.         }
  31.     }
  32.      
  33. checkDrawOverlayPermission();
  34.      
  35. if(Build.VERSION.SDK_INT >= 23) {
  36.      // if (!Settings.canDrawOverlays(this)) {
  37.      //
  38. } else {
  39.      // another similar method that supports device have API < 23
  40. }
  41.      
  42. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  43.   // code for Marshmallow (SDK 23) and newer versions
  44. } else {
  45.   // fallback for older versions
  46. }
  47.      
  48. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  49.  
  50.        if (!Settings.canDrawOverlays(this)) {
  51.         Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
  52.                 Uri.parse("package:" + getPackageName()));
  53.         /** request permission via start activity for result */
  54.         startActivityForResult(intent, REQUEST_CODE);
  55.     }
  56.  
  57.     } else {
  58.      }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top