Click here to Skip to main content
15,911,715 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am writing an app that get the GPS position on a HTC. When the device goes into power off mode, the GPS can`t receive data from any satellite.

What can i do??
Posted
Updated 4-Jun-11 9:00am
v3

thanks again from Joel Ivory Johnson



and solution.....

C#
Code Snippet
const string GPS_DEVICE_NAME_PATH = "DRIVERS\\Builtin\\GPSID";

public string GpsDeviceName

{

   get

   {

     if (_gpsDeviceName == null)

     {

       RegistryKey gpsInfoKey = Registry.LocalMachine.OpenSubKey(GPS_DEVICE_NAME_PATH);

       if (gpsInfoKey != null)

       {

         try

         {

           _gpsDeviceName = String.Format("{0}{1}:", gpsInfoKey.GetValue("Prefix"),    gpsInfoKey.GetValue("Index"));

         }

         catch { }

       }

     }

     return _gpsDeviceName;

   }

}



private void Form1_Load(object sender, EventArgs e)

{

   CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, -1);

   CoreDLL.GetDevicePower(GpsDeviceName, DevicePowerFlags.POWER_NAME, out currentPowerState);

   _gpsPowerRequirements = CoreDLL.SetPowerRequirement(GpsDeviceName, CEDEVICE_POWER_STATE.D0,  DevicePowerFlags.POWER_NAME, IntPtr.Zero, 0);



}

private void Form1_Closing(object sender, CancelEventArgs e)

{

   _gpsDevice.Close();

   CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, 0);

   CoreDLL.ReleasePowerRequirement(_gpsPowerRequirements);

}
 
Share this answer
 
Comments
Hossein Khalaj 9-Jun-11 9:50am    
Hi,,,
when i use this,, my battery of device is empty after 4 hour!!!!!!

what can i for solve this?
I just found out how to fix this issue!!

http://forum.trackr.nl/1211/ShowThread.aspx[^]


this work for kind of HTC device,
not work for my HTC(Touch2).....


but this a solution .

Enjoy it.. :(
 
Share this answer
 
v3
"When the device goes into power off mode, the GPS can`t receive data from any satellite"

That's because it's in power-off mode. Power off means things are turned off. It's by design.
 
Share this answer
 
Comments
Smithers-Jones 4-Jun-11 15:10pm    
Poor design, imo. :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900