-5
我一直在尋找正確的方式來處理MainActivity中的以下代碼,並將結果提交到另一個活動,因此我可以調用URL'http://www.website.com?lat:lng:speed:bearing'這將基於所通過的值。如何將字符串結果拉到另一個類
locationCheck()坐在我的主要活動中,我有一個JSONParse活動,我想使用找到的位置來構造url。我不知道如何分享結果。
在HTML或PHP中,我會使用全局值。
儘管我可以打電話和烤麪包,但我還沒有找到分享結果的最佳方式。
public void locationCheck() {
MyLocation myLocation = new MyLocation();
// this is the result
myLocation.getLocation(this, locationResult);
}
public LocationResult locationResult = new LocationResult() {
public void gotLocation(final Location location) {
try {
double lat = location.getLatitude();
double lng = location.getLongitude();
if (lat != 0.0 && lng != 0.0) {
String sLat;
String sLng;
sLat = Double.toString(lat);
sLng = Double.toString(lng);
String gps_location = sLat + " : " + sLng;
Toast.makeText(getBaseContext(),
"We got gps location! " + gps_location + "",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
}
}
};
,你的問題是什麼? – Blackbelt 2013-05-12 14:41:07
「in to another class」有點含糊 – 2013-05-12 14:42:50
對不起 - 我寫了課的地方,我的意思是活動....重寫。 – 2013-05-12 14:48:34