我的問題是:在)的Android程序如何通過在onPostExecute獲得雙重和字符串數據(的AsyncTask的方法,將接收該數據的另一個活動。例如傳遞double座標和字符串名稱,我得到了onPostExecute()方法,然後將這些字符串數據傳遞給另一個活動。我附上我的代碼。提前致謝。如何從OnPostExecute方法導致
protected void onPostExecute(String result) {
super.onPostExecute(result);
String[] map = result.split("[\":,]");
int i = 64;
int a = 1;
String[] lat = new String[6000];
while (i < 5000) {
lat[a] = map[i];
i = i + 84;
a = a + 1;
}
int i2 = 76;
int a2 = 1;
String[] lng = new String[6000];
while (i2 < 5000) {
lng[a2] = map[i2];
i2 = i2 + 84;
a2 = a2 + 1;
}
int i3 = 1;
map_lat = new double[61];
while (i3 < 60) {
map_lat[i3] = Double.parseDouble(lat[i3]);
Log.i("JSON", "Lat: " + map_lat[i3]);
i3 = i3 + 1;
}
int i4 = 1;
map_lng = new double[61];
while (i4 < 60) {
map_lng[i4] = Double.parseDouble(lng[i4]);
Log.i("JSON", "Lng: " + map_lng[i4]);
i4 = i4 + 1;
}
int i5 = 40;
int a5 = 1;
map_loc = new String[6000];
while (i5 < 4950) {
map_loc[a5] = map[i5];
Log.i("JSON", "Loc: " + map_loc[a5]);
i5 = i5 + 84;
a5 = a5 + 1;
}
int i6 = 58;
int a6 = 1;
map_info = new String[6000];
while (i6 < 4950) {
map_info[a6] = map[i6];
Log.i("JSON", "Info: " + map_info[a6]);
i6 = i6 + 84;
a6 = a6 + 1;
}
double[] ab = map_lat;
double[] ac = map_lng;
String[] ad = map_loc;
String[] ae = map_info;
String af = "0";
public double[] Map(){
double[] ab = map_lat;
double[] ac = map_lng;
String[] ad = map_loc;
String[] ae = map_info;
return ab;
}
double[] ag = Map();
可能重複的[如何將字符串從一個活動發送到另一個?](http://stackoverflow.com/questions/18146614/how-to-send-string-from-one-activity-to-another) – Soham
你在做什麼似乎是一些沉重的計算。它不屬於在UI線程上運行的'onPostExecute'。考慮這樣做在你的'runInBackground'方法 – kiruwka