【发布时间】:2014-07-12 12:31:10
【问题描述】:
我想将我的位置保存在数据库中, 当使用 Jason 解析器时,此错误出现在 (String name = latlng.getText().toString(); )
(对于 LatLng 类型,方法 getText() 未定义)其中 LatLng 来自 LatLng 类型
谁能解决??
protected String doInBackground(String... args) {
String name = latlng.getText().toString();
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("yout_location", name));
// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(add_location,
"POST", params);
// check log cat fro response
Log.d("Create Response", json.toString());
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully created product
Intent i = new Intent(getApplicationContext(), NamesActivity.class);
startActivity(i);
// closing this screen
finish();
} else {
// failed to create product
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
【问题讨论】:
-
尝试使用 latLng.latitude;和 latLng.longitude;.
-
纬度和经度都存储在 Latlng 中,我想将两者保存在一个地方。
-
您是否需要经纬度或从这个经纬度的地方?
-
以经纬度为坐标的地方
标签: java android json location google-maps-android-api-2