android - 如何检测用户何时到达 Google map 中的目的地?我正在通过我的应用程序的 Intent 启动 Google map

标签 android google-maps

这就是我启动谷歌地图的方式。现在我想检测用户何时到达目的地。

    String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?daddr=%f,%f (%s)", drplat, drplong, getAddresss(drplat, drplong));
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
            intent.setPackage("com.google.android.apps.maps");
            try
            {
                context.startActivity(intent);
            }
            catch(ActivityNotFoundException ex)
            {
                try
                {
                    Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                   context.startActivity(unrestrictedIntent);
                }
                catch(ActivityNotFoundException innerEx)
                {
                    Toast.makeText(context, "Please install a maps application", Toast.LENGTH_LONG).show();
                }
            }

最佳答案

您可以使用LocationManager类,特别是它的addProximityAlert成员函数。您指定的 PendingIntent 将在每次手机进入或离开由所提供的位置和半径定义的区域时触发。

addProximityAlert

关于android - 如何检测用户何时到达 Google map 中的目的地?我正在通过我的应用程序的 Intent 启动 Google map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54849173/

相关文章:

javascript - 谷歌地图 : How does Trulia create their custom InfoWIndows?

java - 地理围栏 : GoogleApiClient is not connected yet

java - 设置 DownloadManager 的目标路径

java - 如何从 double 中删除 ".0"?安卓工作室

java - Android - 带滑动功能的 PagerAdapter

java - onMapReady() 函数的类型不兼容

android - 如何定义哪个小部件应该放在主屏幕上以及恢复出厂设置后的哪个位置?

java - Android libGDX 状态更改后没有背景 Sprite

android - addressList 大小为 0 Google map

javascript - 函数令人惊讶地改变传单 map 中的多边形坐标