4

I have an app that also has a NotificationListenerService. When I add breakpoints in that NotificationListenerService, it appears that the breakpoints halt the execution, but the debugger does not recognize it.

The debugger does not seem to see that the execution has paused, and does not activate the continue button nor does it show anything in the service as far as variables. Once this happens the first time, it appears that the service is stopped permanently.

A reboot seems to get things going again sometimes but only if you run the app in normal mode (not debugger mode) before you shut the device off. I tried reattaching the debugger as well, and that does not seem to work. Strangely, I did get it working once or twice. Not sure how.

Does anyone know how to attach the debugger correctly so you can debug the NotificationListenerService?

I found this potentially related question:

, but neither have good answers and neither discuss using the debugger.

Community
  • 1
  • 1
jroal
  • 547
  • 6
  • 16
  • 1
    I found that if you go to settings and remove notification access from your app before deploying a new install, then re-enable notification access for your app after a new run or debug it seems to work much more often. – jroal Jun 19 '16 at 00:43

1 Answers1

1

The NotificationListenerService runs on your main application thread. So to debug first set the debug points and then from Android studio toolbar select "Attach debugger to Android process".

Select your application main process. Now you will be able to debug your service. Hope it helps!

Cheers

Ishaan
  • 3,658
  • 2
  • 23
  • 39