public String newUser = "false";
public double lat = 0.0, lon = 0.0;
我的 android 应用程序中有以下函数(单击按钮时调用),它启动一个线程:
public void SignUpFunction(View view) {
assignValues();
String filledAll = checkIfFilled();
if (filledAll.equals("true")) {
Log.d("LIFECYCLE", "calling thread..");
//my thread
new validateThread().start();
Log.d("After thread start","This log call does not occur");
if (newUser.equals("true")) {
Toast.makeText(this, "Please wait as we obtain your location", Toast.LENGTH_SHORT).show();
getMyLocationFunction();
} else {
return;
}
}
}
验证线程:
class validateThread extends Thread {
public void run() {
Log.d("LIFECYCLE", "validateThread entered...");
try {
newUser = "true";
Log.d("validateThread", "Validated and found new user");
} catch (Exception e) {
Log.d("validateThread", "Exception in validateThread: " + e.getMessage());
}
}
}
线程正确运行......但在最后一行之后,它不会回到它的开始点。我不明白为什么会发生这种情况,因为我以前使用过线程并且它们都可以正常工作。
我知道我可以在线程内提供 getMyLocation 函数,但我真的需要这种方式。
我搜索了类似的问题,但没有任何帮助..我在这里做错了什么?提前致谢。