0

My requirement is to lock my app in foreground for a particular time period. During that time, I have to disable the notification bar like restrict taking incoming calls from the notification. I have tried this post and this one. But am unable to achieve the same. Am checking on my One Plus mobile Android version 13.

When tried these solutions am getting error like: view.WindowManager$BadTokenException: Unable to add window android.view.OplusViewRootImplHooks$ColorW@89ef82e -- permission denied for window type 2010

My gradle config is :

compileSdk 33 minSdk 28 targetSdk 33

It would be great if you can provide me a proper solution.

Regards, Pratheeja

Pratheeja
  • 51
  • 6

1 Answers1

0

this isn't possible without root/high privileges. not possible for "common" apps due to security reasons ofc

snachmsm
  • 17,866
  • 3
  • 32
  • 74
  • Thanks for the reply. So can we achieve this by toggle DND state? I have tried and not working as expected. – Pratheeja Jun 27 '23 at 11:52
  • sadly dunno what is "DND state"... – snachmsm Jun 27 '23 at 19:04
  • DND means Do not disturb mod. – Pratheeja Jun 30 '23 at 04:43
  • afaik main goal of system is to give user access to main components like home button, status bar, soft buttons, app switcher or gesture ALWAYS and common apps won't have ability to overwrite that behavior, just for safety. if user want to exit/kill your app he must be able in 2secs anytime. also hiding anything, especially so much important like system built-in feature - call - also isn't welcome... such possibilities may obtain (probably) only trusted system app, this you are getting `BadTokenException` and `permission denied` – snachmsm Jun 30 '23 at 08:27
  • ok. Thanks for the explanation. – Pratheeja Jul 03 '23 at 04:50