开发者

Android mobile GPS problem

开发者 https://www.devze.com 2023-03-08 16:47 出处:网络
I was working on plotting my traveling ways using GPS in Android mobile phones(Samsung Galaxy GT 15801 & Micromax A60). But sometimes it gives me the wrong lat开发者_如何转开发&long. I was in

I was working on plotting my traveling ways using GPS in Android mobile phones(Samsung Galaxy GT 15801 & Micromax A60). But sometimes it gives me the wrong lat开发者_如何转开发&long. I was in INDIA but it shows me somewhere in middle of Arabian sea and after sometime it shows correct lat&long. Help me to getout of this problem.


use in the activity

LocationManager mlocManager = (LocationManager)getSystemService(this.LOCATION_SERVICE);
            LocationListener mlocListener = new GetGPS(LoginPanel.this);
     Criteria criteria = new Criteria();
                criteria.setAccuracy(Criteria.ACCURACY_FINE);
                criteria.setAltitudeRequired(false);
                criteria.setBearingRequired(false);
                criteria.setCostAllowed(true);
                criteria.setPowerRequirement(Criteria.POWER_LOW);
        String provider = mlocManager.getBestProvider(criteria, true);
             mlocManager.requestLocationUpdates(provider, 0, 0, mlocListener);

just use this as separate class

    public class GetGPS implements LocationListener 
{
    GlobalVariable globalInstance;

    public GetGPS(Context context)
    {

    }
    public void onLocationChanged(Location location) 
    {

        //location.getLatitude();
            //location.getLongitude();


    }
    public void onProviderDisabled(String provider) 
    {
        //alertDialog.showMessage("Please Turn On your GPS", "GPS Turned Off");

    }
    public void onProviderEnabled(String provider) 
    {

    } 
    public void onStatusChanged(String provider, int status, Bundle extras) 
    {

    }
0

精彩评论

暂无评论...
验证码 换一张
取 消