0

We just tested compiling our app (with intercom included) over android 23, everything worked fine on 22 or below devices but when running on android 23 device[Nexus 5] i got this crash:

11-17 12:54:39.804 10431-10431/applock.mindorks.com.applock E/AndroidRuntime: FATAL EXCEPTION: main
 Process: applock.mindorks.com.applock, PID: 10431
 java.lang.RuntimeException: Unable to create service applock.mindorks.com.applock.services.AppCheckServices: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@e40eea -- permission denied for this window type
 at android.app.ActivityThread.handleCreateService(ActivityThread.java:2887)
 at android.app.ActivityThread.-wrap4(ActivityThread.java)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:148)
 at android.app.ActivityThread.main(ActivityThread.java:5417)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@e40eea -- permission denied for this window type
 at android.view.ViewRootImpl.setView(ViewRootImpl.java:591)
 at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:310)
 at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
 at applock.mindorks.com.applock.services.AppCheckServices.onCreate(AppCheckServices.java:88)
 at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
 at android.app.ActivityThread.-wrap4(ActivityThread.java) 
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427) 
 at android.os.Handler.dispatchMessage(Handler.java:102) 
 at android.os.Looper.loop(Looper.java:148) 
 at android.app.ActivityThread.main(ActivityThread.java:5417) 
 at java.lang.reflect.Method.invoke(Native Method) 
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Gautam
  • 1,345
  • 12
  • 30
Sathish Gadde
  • 1,453
  • 16
  • 28

1 Answers1

0

You need to request for permission at runtime in Marshmallow devices for some special permission. E.g. phone state, internet etc.

Check it out.

https://developer.android.com/training/permissions/requesting.html

Here's a SO answer link I've found about this regard too.

Android: Unable to add window. Permission denied for this window type

Community
  • 1
  • 1
Hitesh Danidhariya
  • 709
  • 1
  • 7
  • 14
  • Already done. if (ContextCompat.checkSelfPermission(context, Manifest.permission.SYSTEM_ALERT_WINDOW) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(SplashActivity.this, new String[]{Manifest.permission.SYSTEM_ALERT_WINDOW}, MY_PERMISSIONS_REQUEST_SYSTEM_ALERT); } – Sathish Gadde Nov 17 '16 at 09:59
  • Two Solution I found in Stack Overflow – Hitesh Danidhariya Nov 17 '16 at 11:19
  • http://stackoverflow.com/questions/32224452/android-unable-to-add-window-permission-denied-for-this-window-type – Hitesh Danidhariya Nov 17 '16 at 12:10