iOS Question Is there a way to tell if device on external power?

Discussion in 'iOS Questions' started by Turbo3, Mar 19, 2015.

  1. Turbo3

    Turbo3 Active Member Licensed User

    Is there a way to tell if the iOS device is running on external power instead of off internal battery power?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Yes.
    Code:
    '0 = Unknown, 1 = Unplugged, 2 = Charging, 3 = Full
    Sub BatteryState As Int
       
    Dim no As NativeObject
       no = no.Initialize(
    "UIDevice").RunMethod("currentDevice"Null)
       
    If no.GetField("batteryMonitoringEnabled").AsBoolean = False Then
         no.SetField(
    "batteryMonitoringEnabled"True)
       
    End If
       
    Return no.GetField("batteryState").AsNumber
    End Sub
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice