Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Notification bar height from a service

Tags:

android

The application I'm working on is a service which runs in the background in android. The problem is that I need to determine the height of the notification bar for some functionality of the service.

I found a number of solutions for this, for regular activities - a view inside an activity can determine its own height without the notification bar, based on checking its actual view size from its onSizeChanged event, after it is already drawn. However, this is not applicable to a service which has no physical view drawn.

I would really appreciate any ideas on getting the size of the notification bar at a system level, perhaps?

Thanks so much!

Vitaliy

like image 902
Vitaliy Avatar asked Dec 14 '25 11:12

Vitaliy


1 Answers

Have an activity tell your service the proper size to use. The status bar height, nor the screen size, is likely to change during the operation of your service.

like image 117
CommonsWare Avatar answered Dec 17 '25 02:12

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!