7

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

  • Possible duplicate: http://stackoverflow.com/questions/14495030/get-driving-directions-using-google-maps-api-v2/15053901#15053901. Also, here's a demo app: https://github.com/akexorcist/Android-GoogleDirectionLibrary – Android Enthusiast Apr 20 '16 at 05:58
  • 1
    Unfortunately thats not what i'm looking for. I can get the directions object etc. from google, but i'm looking for a way to get realtime turn by turn directions based on geolocation. – Arthur Van Schravendijk Apr 21 '16 at 11:20
  • I'm looking for the same thing for few days as well. But I don't think those information are accessible. – Lubos Horacek May 09 '16 at 15:41
  • 2
    I noticed that it is possible to read the notification that is placed in the top of the screen. But google maps change it from text like "Go Left", to an icon that displays the turn and I cant get the icon src. Hoped the icon source is something like "sharp_left_notificationicon.png" but cant get its value. I am a android beginner, so maybe you have more luck with getting the value, if so please let me know. If I have anything new ill post it here – Arthur Van Schravendijk May 14 '16 at 11:14
  • I am facing same problem, did you find a solution? @ArthurVanSchravendijk – Dany19 Jul 11 '16 at 19:05
  • @Dany19 sorry for the extreem late response, never found a solution. was a project for graduation. So i let it go and faked it since it was only for a prototype. Hope you had better luck! – Arthur Van Schravendijk May 29 '17 at 13:56
  • I've done a sample application and free library using the NotificationListenerService, you can get it at https://github.com/3v1n0/GMapsParser – Treviño Oct 04 '20 at 23:51

1 Answers1

-1

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);
}
droiddude
  • 177
  • 4
  • 15
  • Thnx for the solution! I have one question about it, With your solution I could create a frame to display the solution in an other place right? Or can I also see if google maps says left or right? Because I would like to use those instructions in code. – Arthur Van Schravendijk Nov 06 '17 at 10:55
  • No, you can also traverse through the `newView` ViewGroup and get the contents of its children: `View viewImage = ((ViewGroup) newView).getChildAt(0);` and the text is inside: `View outerLayout = ((ViewGroup) newView).getChildAt(1);` and then traverse through the `outerLayout` to get the text content. – droiddude Nov 13 '17 at 06:40
  • 1
    @droiddude can you explain your solution in more detail... How exactly does this solution show the directions or instructions that google maps notifications show – jashgopani May 23 '20 at 11:24