下载数据并更新MapView
我正在寻找一些指导,希望有人能告诉我实现此场景的正确方法。在我的应用程序中,我将在启动时显示启动画面,并立即开始从互联网下载一些数据。当启动屏幕完成后,大约三秒钟后,应该显示地图视图。当数据下载完成后,大约一到十秒后,地图视图应该更新为与下载数据相关的兴趣点。我如何在 Android 中最好地实现这一点。当然,我首先有一个用于启动屏幕的活动和另一个用于地图视图的地图活动。但是我用什么来下载数据并在完成后通知mapactivity更新mapview呢?我使用异步任务吗?
的问候
最好
I am looking for some guidance and hopefully someone can tell me the proper way to implement this scenario. In my app I am going to show a splash screen on startup and immediately start downloading some data from internet. When splash screen is finished, after about three seconds, the mapview should be shown. When the downloading of data is finished, after about one to ten seconds, the mapview should be updated with points of interest relating to the downloaded data. How do I best implement this in Android. Of course I first have an activity for the splash screen and another mapactivity for the mapview. But what do I use to download the data and when it is finished notify the mapactivity to update the mapview? Do I use an asynctask?
Best regards
P
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SplashScreen 不需要是一个单独的 Activity,因为它不处理用户事件。
只需将启动屏幕和地图视图放入一个活动中即可。使用
FrameLayout
将启动屏幕放置在地图视图顶部。当 Activity 启动时(onCreate)开始加载数据。使用 AsyncTask 在后台进行网络通信,同时在数据到达时正确更新视图。
创建
Handler
并调用postDelayed()
以在一段时间后关闭启动屏幕。SplashScreen does not need to be a separate Activity since it does not handle user events.
Just put splash screen and mapview inside one activity. Use
FrameLayout
to position splash screen on top of mapview.Start loading data when Activity starts (onCreate). Use AsyncTask to do network communication in the background while correctly updating view when data arrives.
Create
Handler
and callpostDelayed()
to dismiss splash screen after some time.