Question

Here is my code. I use eclipse with an avd and i sent it the coordinates i want. I saw that if a use an avd with API 7 or higher, my application works fine, but if i use an avd with API 3, it accept only 3 points and then it stops accepting other coordinates (i still don't know if there is the same problems with api 4-5-6 because i'm trying it now). EDIT: API 4 is ok.

public class myActivity extends Activity 
{

    private TextView mytext;
    private LocationManager locmgr = null;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        GPSListener gpsListener=newGPSListener();
        mytext = (TextView) findViewById(R.id.mytext);

        //grab the location manager service
        locmgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        locmgr.requestLocationUpdates(locmgr.GPS_PROVIDER, 10, 10, gpsListener);

        mytext.setText("waiting for location");
    }

    //Start a location listener
    private class GPSListener implements LocationListener
    {
        public void onLocationChanged(Location loc) 
        {
            //sets and displays the lat/long when a location is provided
            String latlong = "Lat: " + loc.getLatitude() + " Long: " + loc.getLongitude();   
            mytext.setText(latlong);
        }

    public void onProviderDisabled(String provider) 
    {

    }

    public void onProviderEnabled(String provider) 
    {

    }

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

    }
}
 }
Was it helpful?

Solution

Mmh can't say what's really happening, but I'd suggest not to concern about Api Levels prior 8 (2.2).

As you can see in Android Developer Dashboards, android users prior Api level 8 have literally disappeared (even Api level 8 is almost 'deprecated')

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top