1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
localisationRES=(TextView) findViewById (R.id.localisationRES);
localisationGPS=(TextView) findViewById (R.id.localisationGPS);
localisationPAS=(TextView) findViewById (R.id.localisationPAS);
LoMa= (LocationManager) this.getSystemService(LOCATION_SERVICE);
IntentFilter filterLo = new IntentFilter();
filterLo.addAction(LocationManager.KEY_LOCATION_CHANGED);
filterLo.addAction(LocationManager.PROVIDERS_CHANGED_ACTION);
registerReceiver( mReceiverLo , filterLo);
}
private class my_ReceiverLo extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
if (LoMa.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)!=null)
LocalisationRES.setText("Réseaux:"+"Latitude="+LoMa.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getLatitude()+"Longitude="+LoMa.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getLongitude());
else
localisationRES.setText("Réseaux: null");
if (LoMa.getLastKnownLocation(LocationManager.GPS_PROVIDER)!=null)
localisationGPS.setText("GPS: "+"Latitude="+LoMa.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude()+" Longitude="+LoMa.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLongitude());
else
localisationGPS.setText("GPS: null");
if (LoMa.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER)!=null)
localisationPAS.setText("Passive: "+"Latitude="+LoMa.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER).getLatitude()+"Longitude="+LoMa.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER).getLongitude());
else
localisationPAS.setText("Passive: null");
} |
Partager