I'm trying to build a Java app that reads the status of a laptop battery and sends a notification to the user if it's low. In order to do this, I'm using jna with Kernel32 native library as explained in the first answer of this question: How to get the remaining battery life in a Windows system?
Running the example, the program yields this output:
ACLineStatus: Offline
Battery Flag: High, more than 66 percent
Battery Life: Unknown
Battery Left: 0 seconds
Battery Full: 10832 seconds
The fields battery life and battery left are read in Kernel32 BatteryLifePercent and BatteryLifeTime values which are 255 (Unknown) and 0 (I don't get this value. Unknown would be -1 according to Microsoft documentation here: https://msdn.microsoft.com/en-us/library/windows/desktop/aa373232(v=vs.85).aspx).
My question is: why am I getting these values back? The Windows battery tray icon displays the correct percentage, so why I can't get that data from here?
I'm running Windows 7 Ultimate Edition 64-bit.
Thank you.