错误:
logUser("An error happend while creating graph:"+ getErrorMessage());
getErrorMessage()
无法在线程中创建handler,线程没有调用Looper.prepare()
,而logUser 是用来显示toast信息的函数。
void prepareGraph() {
logUser("loading graph (" + Helper.VERSION + "|" + Helper.VERSION_FILE
+ ") ... ");
new MyAsyncTask<Void, Void, Path>() {
protected Path saveDoInBackground(Void... v) throws Exception {
GraphHopper tmpHopp = new GraphHopper().forAndroid();
tmpHopp.contractionHierarchies(true);
tmpHopp.load(mapsFolder + currentArea);
logUser("found graph with " + tmpHopp.getGraph().nodes() + " nodes");
hopper = tmpHopp;
return null;
}
protected void onPostExecute(Path o) {
if (hasError()) {
logUser("An error happend while creating graph:"
+ getErrorMessage());
} else {
logUser("Finished loading graph. Touch to route.");
calcPath(52.534185, 13.348732, 52.53857,
13.41259);
}
finishPrepare();
}
}.execute();
}