Android应用程序,以检测当谷歌地图的方向完成 [英] Android application to detect when Google maps direction is finished

查看:243
本文介绍了Android应用程序,以检测当谷歌地图的方向完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个Android应用程序,这将显示出某些点上的谷歌地图,这是我(LAT,郎)的所有点显示,跟我来。无论何时,用户点击了谷歌地图,这些位置中的一个,我开始一个新的谷歌地图的意图,显示导航给用户,并应该采取用户到(LAT,郎)。

I am building an android application, that will show certain points on google maps, for which I have (lat,lang) for all the points shown, with me. Whenever, a user clicks on one of these locations on google maps, I am starting a new Google Maps intent which shows navigation to the user and is supposed to take the user to that (lat, lang).

//suppose this function is called on onclick of google maps event
    function onclick(){
            Uri gmmIntentUri = Uri.parse("google.navigation:q=32.885240,-96.763475");
            Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
            mapIntent.setPackage("com.google.android.apps.maps");
            if (mapIntent.resolveActivity(getPackageManager()) != null) {
                startActivity(mapIntent);
            }
    }

这将启动用户的导航。现在我想实现是这样的 - 每当这个导航是完整的,我想某种标志要传递给我的Andr​​oid应用程序,让自己的应用程序知道导航已完成

This will start the navigation for the user. Now what I want to achieve is this - Whenever this navigation is complete, I want some kind of flag to be passed to my android application, so that my application knows that the navigation has been finished.

如果有可能的导航已经完成后自动关闭谷歌地图应用程序,这将是不错的。

If it is possible to automatically close the google maps application after the navigation has been completed, it will be nice to have.

推荐答案

由于@Daniel提到的,你可以使用的onActivityResult()当用户回来检测。但是,如果你真的想检测是否谷歌地图的方向已经完成了...你可以看一下通知。

As @Daniel mentioned, you can use onActivityResult() to detect when users are back. However, if you really want to detect if Google maps direction had finished... You can look at the notifications.

所以这里美中不足的是,在谷歌地图的方向是一个服务,它运行时,它张贴更新到通知中心。

So the catch here is, when Google Maps direction is a services, and when it is running, it posts updates to the notifications center.

这意味着要么你能守望着什么服务正在运行,或...得到许可的通知中心,并保持检查是否谷歌地图存在。

Which means either you can keep looking at what services are running, or.. get permission to the notifications center and keep checking if Google Maps exists.

这篇关于Android应用程序,以检测当谷歌地图的方向完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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