获取Google地图导航说明 [英] Get Google Maps Navigation Instructions
问题描述
我正在寻找从地图导航中获取说明的方法。
目前我认为唯一可能的方法是阅读地图导航位于顶部的通知数据。我的理由是,这是唯一的方法来自帖子。
我尝试使用OnNotificationPosted方法获取数据,但我无法在StatusBarNotification对象中查找路线数据...
I'm looking for a way to get the instructions from Maps Navigation. Currently I think the only possible way is to read the notification data that is placed at the top by Maps Navigation. My reason for beleving that this is the only way comes from this post. I tried getting the data with the OnNotificationPosted method, but i cant find directions data in the StatusBarNotification object...
有没有人有解决方案或更好的想法关于如何实现此功能
Does anyone have a solution or better idea on how to achieve this
推荐答案
您可以实现 NotificationListenerService 以检索Google地图路线方向的内容。不幸的是,地图没有使用StatusBarNotification中的通用属性。不过,地图使用 RemoteViews
来显示内容。
您可以通过广播将此数据发送到活动,并最终将内容添加到现有视图:
You can implement a NotificationListenerService in order to retrieve the content of google maps route direction. Unfortunately Maps is not using the common attributes within the StatusBarNotification. However maps uses RemoteViews
to display content.
You can send this data via Broadcast to the activity and eventually add the content to an existing view:
RemoteViews remoteView = intent.getParcelableExtra(id);
if (remoteView != null) {
ViewGroup frame = (ViewGroup) findViewById(R.id.layout_navi);
frame.removeAllViews();
View newView = remoteView.apply(getApplicationContext(), frame);
newView.setBackgroundColor(Color.TRANSPARENT);
frame.addView(newView);
}
这篇关于获取Google地图导航说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!