Art*_*ijk 5 navigation notifications android google-maps android-notifications
我正在寻找一种从地图导航中获取说明的方法。目前我认为唯一可能的方法是读取地图导航放置在顶部的通知数据。我相信这是唯一方法的原因来自这篇文章。我尝试使用 OnNotificationPosted 方法获取数据,但我无法在 StatusBarNotification 对象中找到路线数据...
有没有人有关于如何实现这一目标的解决方案或更好的想法
dro*_*ude -1
您可以实现NotificationListenerService以检索谷歌地图路线方向的内容。不幸的是,地图没有使用 StatusBarNotification 中的通用属性。然而,地图用于RemoteViews显示内容。您可以通过广播将此数据发送到活动,并最终将内容添加到现有视图中:
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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1925 次 |
| 最近记录: |