Q:

How to get battery level of Onyx ibeacons

I am using altbeacon library.And I use onyxBeacon ibeacons. I examine this and this  post. But its not work for me.
public void onBeaconServiceConnect() {
    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(final Collection<Beacon> beacons, Region region) {               
            if (beacons.size() > 0) {                  
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        // MyCustomFunction();
                    }
                 });
            }

            for (Beacon b : beacons) { 
                long batteryLevel = b.getDataFields().get(0);
            }
        }
    });
}

'batterylevel' return same value.
How can i get the battery level from the beacon?

A:

There is no standard way to get the battery level for an iBeacon.  Some manufacturers like Kontakt store the battery level in an extra byte at the end of the broadcast, which is true for the post you reference.  However, this will not work for all manufacturers.
Another common way to get the info is with a proprietary connectable Bluetooth LE service.  It is unclear whether the beacons you are using have this capability.  Even if they do, you need to be able to get a public API from the manufacturer to figure out how to do it.  If the manufacturer does not publish this, then you are out of luck unless you can reverse engineer it yourself.
Again, every manufacturer is different, so you must find a different solution for each beacon type.  

