package com.santosh.map;
import android.app.Activity;
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;
public class FindMyLocation extends Activity implements LocationListener{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LocationManager locationmanger=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
Criteria c=new Criteria();
c.setAccuracy(Criteria.ACCURACY_FINE);
c.setAltitudeRequired(false);
c.setBearingRequired(false);
c.setCostAllowed(true);
c.setPowerRequirement(Criteria.POWER_LOW);
String provider=locationmanger.getBestProvider(c, true);
Location location=locationmanger.getLastKnownLocation(provider);
locationmanger.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
0, 0, this);
}
@Override
public void onLocationChanged(Location location) {
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
System.out.println("Lat:"+location.getLatitude());
System.out.println("Lat:"+location.getLongitude());
System.out.println("Lat:"+location.getAccuracy());
System.out.println("Lat:"+location.getAltitude());
System.out.println("Lat:"+location.getBearing());
System.out.println("Lat:"+location.getProvider());
System.out.println("Lat:"+location.getSpeed());
System.out.println("Lat:"+location.getTime());
}
Toast.makeText(FindMyLocation.this, "onLocationChanged", 1).show();
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
Toast.makeText(FindMyLocation.this, "onProviderDisabled", 1).show();
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
Toast.makeText(FindMyLocation.this, "onProviderEnabled", 1).show();
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
Toast.makeText(FindMyLocation.this, "onStatusChanged", 1).show();
}
}
import android.app.Activity;
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;
public class FindMyLocation extends Activity implements LocationListener{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LocationManager locationmanger=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
Criteria c=new Criteria();
c.setAccuracy(Criteria.ACCURACY_FINE);
c.setAltitudeRequired(false);
c.setBearingRequired(false);
c.setCostAllowed(true);
c.setPowerRequirement(Criteria.POWER_LOW);
String provider=locationmanger.getBestProvider(c, true);
Location location=locationmanger.getLastKnownLocation(provider);
locationmanger.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
0, 0, this);
}
@Override
public void onLocationChanged(Location location) {
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
System.out.println("Lat:"+location.getLatitude());
System.out.println("Lat:"+location.getLongitude());
System.out.println("Lat:"+location.getAccuracy());
System.out.println("Lat:"+location.getAltitude());
System.out.println("Lat:"+location.getBearing());
System.out.println("Lat:"+location.getProvider());
System.out.println("Lat:"+location.getSpeed());
System.out.println("Lat:"+location.getTime());
}
Toast.makeText(FindMyLocation.this, "onLocationChanged", 1).show();
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
Toast.makeText(FindMyLocation.this, "onProviderDisabled", 1).show();
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
Toast.makeText(FindMyLocation.this, "onProviderEnabled", 1).show();
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
Toast.makeText(FindMyLocation.this, "onStatusChanged", 1).show();
}
}
No comments:
Post a Comment