android - 如何检测用户何时到达谷歌地图中的目的地?我正在通过我的应用程序中的意图启动 Google 地图
问题描述
这就是我启动谷歌地图的方式。现在我想检测用户何时到达目的地。
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
每次手机进入或离开由位置和提供的半径定义的区域时,都会触发您指定的。
推荐阅读
- javascript - 使用 javascript 获取每毫秒、秒
- python - 重复一个 Numpy 数组以匹配另一个数组的维度
- python - 当 python 应用程序尝试将日志文件写入 docker 中的共享卷时权限被拒绝
- jenkins - MSBuild 错误 msb1009 项目文件不存在。詹金斯
- swift - 应用程序跟踪透明度对话框不会出现在 iOS 上
- faunadb - 如何将 JavaScript 中的 FQL 查询打印为字符串(例如在 Fauna shell 中对其进行测试)?
- android - 具有可绘制背景的布局上的动态背景图像
- python - 无法使用 Linux Alpine docker 为 AWS lambda 构建 zip 文件
- r - R:如何获取数据中的因子水平
- javascript - 我的 Javascript AVG 计算器不起作用。我该如何解决?