.NET Components for Mobility

Detect if device is connected to a power supply (charger)

Last post 08-29-2008 4:04 AM by DaveK17. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 08-25-2008 3:41 AM

    Detect if device is connected to a power supply (charger)

     Hi everyone.

    I am developing an App for windows mobile 5 using Mobile In the hand 3.3, and I need to detect when the user plugs the device into a power supply, not to detect cradle mode using Active Sync, no, just when the user connects the battery charger.

    By the way, it would be great if I an event would be raised. 

    Thanks a lot. 

  • 08-25-2008 10:26 AM In reply to

    Re: Detect if device is connected to a power supply (charger)

     Sorry about the auto-reply, but I think I got it.

    I want to check if this is a good way to do it using In the hand mobile :

    I work on C# :

    private SystemState status;

    status= new SystemState(SystemProperty.PowerBatteryState);
    status.Changed += new ChangeEventHandler(status_Changed);

         
    void status_Changed(object sender, ChangeEventArgs args)
    {
                MessageBox.Show(args.NewValue.ToString());
    }
     

    Whe I plug the charger I got a value of 2 , unplugging it I get 0.

     What do you think about it ?

    Thanks. 

  • 08-26-2008 11:20 AM In reply to

    Re: Detect if device is connected to a power supply (charger)

    You can cast the value to the InTheHand.WindowsMobile.Status.BatteryState enumeration type. 0 is Normal, 2 is charging with other values for Low, Critical etc

    Peter

    Peter Foot
    Microsoft Device Application Development MVP
    www.peterfoot.net | www.inthehand.com
  • 08-27-2008 7:38 AM In reply to

    Re: Detect if device is connected to a power supply (charger)

     The code that I posted above, works fine but there is still an issue ..., once the device's battery is fully charged, the status changes, and I lose the charging state.

    Right now, I don't know how to detect that there's a charger pulgged in once the battery is fully charged.

    Perhaps I should try to get the display's power safe state (I do not know its real name Stick out tongue ) ?

    Because when you plug the charger, the display increases its brightness, but I don't know how to do it.

    Any idea ?

    Thanks very much.

    --

    Ibán.

  • 08-29-2008 4:04 AM In reply to

    Re: Detect if device is connected to a power supply (charger)

     

Page 1 of 1 (5 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.