I am developing a game for Android. It uses a surface view and uses Bitmaps to draw objects each frame, redrawing on the Bitmap objects only when required. Using the app I noticed that the battery is draining. I would like to know if there is a library to understand which part I am consuming a lot of battery in or a way to apply the battery safety function in my surface view. Each bitmap in the game is recycled every time it is instantiated. So apart from this little trick I don't know how to optimize my code. Can anyone suggest me what I can do? Thanks in advance
There is no exact solution to minimize battery usage - it depends on your code, and it's all about minimizing CPU & Network usage. Basically you already have powerful Profiler in your Android Studio. It shows CPU, RAM, network & battery usage on dashboards and you can find most heavy part of your code using it. More you optimize your code, more effectively app will use battery.