The GPS icon appears to change state according to broadcast intentions. You can change your state yourself using the following code samples:
Report GPS enabled:
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE"); intent.putExtra("enabled", true); sendBroadcast(intent);
Report GPS getting corrections:
Intent intent = new Intent("android.location.GPS_FIX_CHANGE"); intent.putExtra("enabled", true); sendBroadcast(intent);
Report that GPS no longer receives corrections:
Intent intent = new Intent("android.location.GPS_FIX_CHANGE"); intent.putExtra("enabled", false); sendBroadcast(intent);
Report that GPS is disabled:
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE"); intent.putExtra("enabled", false); sendBroadcast(intent);
Example code for registering the receiver: [/ p>
// MyReceiver must extend BroadcastReceiver MyReceiver receiver = new MyReceiver(); IntentFilter filter = new IntentFilter("android.location.GPS_ENABLED_CHANGE"); filter.addAction("android.location.GPS_FIX_CHANGE"); registerReceiver(receiver, filter);
After receiving these broadcasts, you may notice a change in GPS status. However, you will only be notified if the status changes. Therefore, it is not possible to determine the current state using these intentions.
sast Nov 03 '10 at 6:56 2010-11-03 06:56
source share