我的手机应用需要在符合某些要求时自动在仪表板上启动Google地图(或导航)。 但是在检查此链接时 https://developer.android.com/auto/index.html 看起来他们只允许音频和消息,或者我错过了什么? 感谢
答案 0 :(得分:2)
我想从通知回复中你的应用可以启动谷歌地图意图。
您可以在app Manifest中定义MyMessageReplyReceiver:
<receiver android:name=".MyMessageReplyReceiver">
<intent-filter>
<action android:name="com.myapp.messagingservice.MY_ACTION_MESSAGE_REPLY"/>
</intent-filter>
</receiver>
然后关注these explanations on How to Handle User Action,您可以使用意图从应用中启动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);
}
}
仅供参考:我还没有对它进行测试,只考虑过如何做到这一点
答案 1 :(得分:-1)
您的手机上没有Android Auto平台。这是一个全新的设备。就像现代汽车中的单板电脑,但随后安装了Android Auto。
如果您想要启动Google地图应用,则需要查看手机,而不是查看您的车载电脑。如果这就是你想要的,我建议写一个接收蓝牙连接消息的广播接收器,检查它是否是正确的设备,然后打开谷歌地图应用。