【发布时间】:2014-10-17 04:59:45
【问题描述】:
我已使用以下代码获取我的设备位置。有没有更好的方法来获取确切地址或谷歌地图的位置,我想将位置存储在我的数据库中MySQL。
public class Finder extends Activity implements LocationListener{
protected LocationManager locationManager;
protected LocationListener locationListener;
protected Context context;
TextView txtLat;
String lat;
String provider;
protected String latitude,longitude;
protected boolean gps_enabled,network_enabled;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtLat = (TextView) findViewById(R.id.textview1);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
}
@Override
public void onLocationChanged(Location location) {
txtLat = (TextView) findViewById(R.id.textview1);
txtLat.setText("Latitude:" + location.getLatitude() + ", Longitude:" + location.getLongitude());
}
@Override
public void onProviderDisabled(String provider) {
Log.d("Latitude","disable");
}
@Override
public void onProviderEnabled(String provider) {
Log.d("Latitude","enable");
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.d("Latitude","status");
}
【问题讨论】:
-
您似乎想使用 Google Maps API 来做您想做的事。
-
抱歉,我不知道 Google Maps API。我的基本想法是获取设备的确切位置,但我对仅获取经度和纬度值不满意,因为我还必须将位置存储在我的数据库中
-
在数据库中保存位置详细信息后你会做什么?
-
您可以使用 Google Maps API 发送位置,并取回各种信息(包括“英文”位置信息,例如地址等)。去 Google 并检查这些信息。跨度>
-
对不起桑迪普先生,我不能提供这些细节
标签: java android mysql google-maps