【发布时间】:2011-05-28 16:06:57
【问题描述】:
所以我从手机获取位置修复,如果它永远找不到位置或花费太长时间,就会出现问题。下面是加载屏幕的示例代码
我如何设置一个计时器来停止线程(加载屏幕)一旦经过一定的时间?
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
1000, 10f, 这个);
处理程序处理程序 = 新处理程序(); Runnable showWaitDialog = new Runnable() { int等待= 0; @覆盖 公共无效运行(){ while (loc == null) {
}
// After receiving first GPS Fix dismiss the Progress Dialog
dialog.dismiss();
} };
// 创建一个对话框让用户知道我们正在等待 GPS 定位 dialog = ProgressDialog.show(Weather.this, "请稍候...", "正在检索 GPS 数据...", true);
线程 t = 新线程(showWaitDialog); t.start();
【问题讨论】:
标签: android multithreading location