MizoRedDevil
Lurker
Hi,
I'm a new coming in the world of android, I wanted to make a simple application that can display my location in real time , but i can't have a result here's my code :
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.widget.Toast;
public class SampleGPS extends Activity
{
private LocationManager locationManager;
private LocationListener locationListener;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
System.out.println("etape une");
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
System.out.println("etape deux");
locationListener = new MyLocationListener();
System.out.println("etape trois");
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener);
System.out.println("etape quatre");
}
private class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
System.out.println("Position Changed");
if (loc != null)
{
Toast.makeText(getBaseContext(), "Localisation actuelle :\n Lat: " + loc.getLatitude() + " Lng: " + loc.getLongitude(),Toast.LENGTH_SHORT).show();
}
}
public void onProviderDisabled(String provider)
{
System.out.println(provider+" Est D
I'm a new coming in the world of android, I wanted to make a simple application that can display my location in real time , but i can't have a result here's my code :
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.widget.Toast;
public class SampleGPS extends Activity
{
private LocationManager locationManager;
private LocationListener locationListener;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
System.out.println("etape une");
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
System.out.println("etape deux");
locationListener = new MyLocationListener();
System.out.println("etape trois");
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener);
System.out.println("etape quatre");
}
private class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
System.out.println("Position Changed");
if (loc != null)
{
Toast.makeText(getBaseContext(), "Localisation actuelle :\n Lat: " + loc.getLatitude() + " Lng: " + loc.getLongitude(),Toast.LENGTH_SHORT).show();
}
}
public void onProviderDisabled(String provider)
{
System.out.println(provider+" Est D