我的问题是:在)的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