所有我想要做的是返回从最后一个知道位置的长/纬度值,如果这是null然后拉新的coords。Android位置管理器?
我很新的这一点,这是我有:
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;
public class GPS extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
TextView output;
output = (TextView) findViewById(R.id.output);
output.append("\n\nLocations (starting with last known):");
Location location = locationManager.getLastKnownLocation(bestProvider);
printLocation(location);
}
}
你得到了什么错误或者你的EditText输出是什么? – 2011-06-02 16:40:19
它只是强制关闭,我甚至不能运行它。 – Nick 2011-06-02 16:44:35
在这种情况下,您应该发布LogCat输出。 – 2011-06-02 16:53:38