Android的显示进度对话框在等待位置 [英] Android show progress dialog while waiting for location

查看:248
本文介绍了Android的显示进度对话框在等待位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个例子开发基于位置的应用程序: http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/

I'm developing location based app using this example: http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/

但是,当我打开手机,位置不在那一刻使用权。所以,我想显示进度对话框在等待位置。想使用AsyncTask的做到这一点的背景。

But when I turn on phone, the location isn't available right on that moment. So I would like to show progress dialog while waiting for the location. Wanna do this in the background using AsyncTask.

您可以给任何想法如何以及在哪里做?

Can you give any ideas how and where to do that?

推荐答案

有没有必要的AsyncTask的,因为位置服务已经在不同的进程中运行,就贯彻落实 LocationListener的和注册它的resume方法,并在onCreateActivity检查,如果位置为空,则显示 ProgressDialog ,而在 onLocationChanged()设置位置和关闭 ProgressDialog

There is no need of AsyncTask because Location service already running in different process, Just implement the LocationListener and register it on resume method, and in onCreateActivity check if location is null, the show the ProgressDialog, and in onLocationChanged() set the location and close the ProgressDialog

这篇关于Android的显示进度对话框在等待位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆