Android Question How to understand which portion of code consumes the most battery?

amorosik

Expert
Licensed User
I have an Android app that connects to a mqtt broker, via telephone network, to exchange data with the main db residing on a Windows PC
I'm noticing that leaving the app on the battery consumption of the device, in my case a tablet, is much greater than when the app is not active
I would try to optimize the app, to reduce battery consumption
Question is: how to understand which areas of the code are the ones that consume more energy than others?
 

amorosik

Expert
Licensed User
It's a tablet, a Samsung Tab 6 lite, with its book case that turns off the display when the cover is closed
Looking at the battery, consumption appears from highest to lowest, and wifi seems to be the main consumption, then the display, immediately after there is the app I'm trying to optimize
I assume that the most energy-intensive part is the connection via mqtt with a remote telephone network broker, but I'm not sure
No way to measure the instantaneous consumption of an app?
 
Upvote 0
Top