首页 文章

在不解锁设备的情况下打开Google Map意图

提问于
浏览
1

我有一个使用以下意图的应用程序,以便在Google Map上显示一组位置并根据用户选择开始方向:

Intent intent =
    new Intent(Intent.ACTION_VIEW,
        Uri.parse("geo:0,0?q=" + Uri.encode("mykeyword") + "&z=14"));
        // force to use Google maps
intent.setClassName(
    "com.google.android.apps.maps",
    "com.google.android.maps.MapsActivity");

意图如下:

try {
    startActivity(intent);
} catch (ActivityNotFoundException e) {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.apps.maps")));
}

代码由我在锁定屏幕上显示的应用活动触发(感谢 android:showOnLockScreen="true" 属性) . 这意味着在使用intent时设备被锁定 .

不幸的是,意图要求用户解锁设备才能访问Google Map活动 .

我正在寻找一种方法来显示与意图相关的活动,而无需用户解锁他/她的设备 .

我现在唯一的解决方案是重新实现 com.google.android.maps.MapsActivity 在我自己的活动中所做的事情 . 不幸的是,这只是模仿现有Google Map意图所做的工作(即显示给定关键字的位置,提供更改关键字的字段,显示建议列表,详细视图和方向等等) . 有良好的用户体验) .

任何有这种情况的经验或想法都是受欢迎的 .

1 回答

  • -1

    我得到的是你想要使用你的应用程序,无论是谷歌 Map 导航,屏幕是锁定还是解锁,对吧?

相关问题