Sub Process_Globals
Dim nativeMe As JavaObject
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
nativeMe.InitializeContext
End If
Msgbox(nativeMe.RunMethod("getBatteryLevel", Null) & " %", "BatteryLevel")
End Sub
#If JAVA
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
public float getBatteryLevel() {
Intent batteryIntent = registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
return ((float)level / (float)scale) * 100.0f;
}
#End If