Is there any way to profile the battery usage by the application in development environment or real time? BatteryManager seems not providing any per application API
You may want to take a look at Trepn Profiler by Qualcomm. Its features are:
I don't think that is possible at the moment.
There is a private API, PowerProfile, for retrieving battery consumption on a subsystem level (see http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.2_r1.1/com/android/internal/os/PowerProfile.java). Also take a look at the code for the fuel gauge you find in Android's settings on how they calculate power consumption: http://google.com/codesearch/p?hl=en#ohAXAHj6Njg/src/com/android/settings/fuelgauge/PowerUsageSummary.java
There's a new tool called "little eye" that does this.
It can profile Battery, CPU, Wifi and Data usage for an App in a development environment. Its a commercial product, but in beta right now, so free to download (for the moment). (disclaimer: I work at little eye)
http://www.littleeye.co
you can use the two classes: IBatteryStats
and BatteryStatsImplernal
in package com.android.internal
, they provide methods to get the statistics of battery usage.