android avd不接受3个以上的坐标

时间:2013-09-12 13:21:20

标签: java android api gps locationlistener

这是我的代码。我使用带有avd的eclipse,我发送了它想要的坐标。我看到如果使用API​​ 7或更高版本的avd,我的应用程序工作正常,但如果我使用带有API 3的avd,它只接受3点,然后它停止接受其他坐标(我仍然不知道是否有与api 4-5-6相同的问题因为我现在正在尝试)。 编辑:API 4没问题。

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) 
    {

    }
}
 }

1 个答案:

答案 0 :(得分:0)

Mmh无法说出真正发生的事情,但我建议不要关注8(2.2)之前的Api等级。

正如你在Android Developer Dashboards中看到的那样,在Api等级8之前的Android用户实际上已经消失了(即使Api等级8几乎已被弃用')