0

我的手机应用程序需要在满足某些要求时自动在仪表板上启动谷歌地图(或导航)。但是,当检查此链接 https://developer.android.com/auto/index.html 时,它们似乎只允许音频和消息,或者我错过了什么?谢谢

4

2 回答 2

2

我猜从通知回复中您的应用程序可以启动谷歌地图意图。

您将在您的应用清单中定义一个 MyMessageReplyReceiver:

<receiver android:name=".MyMessageReplyReceiver">
    <intent-filter>
      <action android:name="com.myapp.messagingservice.MY_ACTION_MESSAGE_REPLY"/>
    </intent-filter>
</receiver>

然后按照这些关于如何处理用户操作的解释,您将使用意图从您的应用程序启动 Google 地图:

    public class MyMessageReplyReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        /* Intent code to start Google Maps */
        // Create a Uri from an intent string. Use the result to create an Intent.
        Uri gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988");

        // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW
        Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
        // Make the Intent explicit by setting the Google Maps package
        mapIntent.setPackage("com.google.android.apps.maps");

        // Attempt to start an activity that can handle the Intent
        context.startActivity(mapIntent);
    }
}

仅供参考:我还没有测试它,只是想我会怎么做

于 2015-03-26T13:57:34.653 回答
-1

Android Auto 平台不在您的手机上。这是一个全新的设备。就像现代汽车中的车载电脑,但安装了 Android Auto。

如果您想启动 Google 地图应用程序,您需要查看您的手机,而不是查看您的车载电脑。如果这是你想要的,我建议编写一个接收蓝牙连接消息的广播接收器,检查它是否是正确的设备,然后打开谷歌地图应用程序。

于 2015-03-25T14:53:15.110 回答