Android Question How to access Google Navigation with Notification Listner?

kolpolok

Member
Licensed User
Longtime User
Hi, Google navigation uses a custom view for its turn by turn display instruction in the notification pane. With notification listener I cannot access those values. I know its possible since I have seen a lot of apps to access that. Will be really helpful if anyone can show me the way. If it helps below is the xml for the resource file.

B4X:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@id/notification_container" android:layout_width="fill_parent" android:layout_height="wrap_content" android:minHeight="64.0dip"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageView android:id="@id/nav_notification_icon" android:paddingTop="12.0dip" android:layout_width="@android:dimen/notification_large_icon_width" android:layout_height="@android:dimen/notification_large_icon_height" android:scaleType="center" android:paddingStart="12.0dip" android:paddingEnd="12.0dip" />
    <LinearLayout android:orientation="vertical" android:paddingTop="12.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingEnd="24.0dip" style="@style/NavNotificationContentContainer">
        <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" style="@style/NavNotificationContentLine">
            <TextView android:textSize="16.0dip" android:textColor="#ffffffff" android:ellipsize="marquee" android:gravity="bottom" android:id="@id/nav_title" android:layout_width="fill_parent" android:layout_height="0.0dip" android:singleLine="true" android:layout_weight="1.0" android:textAlignment="viewStart" />
            <TextView android:textSize="16.0dip" android:textColor="#ffffffff" android:gravity="center_vertical" android:id="@id/nav_description" android:layout_width="fill_parent" android:layout_height="wrap_content" android:maxLines="2" android:minLines="2" android:textAlignment="viewStart" />
            <TextView android:textSize="14.0dip" android:textColor="#ffffffff" android:gravity="top" android:id="@id/nav_time" android:layout_width="fill_parent" android:layout_height="0.0dip" android:singleLine="true" android:layout_weight="1.0" android:textAlignment="viewStart" />
        </LinearLayout>
        <ImageView android:layout_width="fill_parent" android:layout_height="1.0dip" android:layout_marginTop="6.0dip" style="@style/NavNotificationHorizontalDivider" />
        <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" style="@style/NavNotificationContentLine">
            <Button android:id="@id/dismiss_nav" android:textAlignment="viewStart" style="@style/NavNotificationDismissButton" />
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>
 

kolpolok

Member
Licensed User
Longtime User
How do you integrate Google Navigation inside your app? Isn't it a web service?
Navigation is part of Google Maps app. I meant the turn by turn navigation that appears in the notification panel from the Maps app. Benefit of accessing this notification is that it works offline with downloaded maps.
 
Upvote 0

kolpolok

Member
Licensed User
Longtime User
(Bundle) Bundle[{android.title=null, android.subText=null, android.showChronometer=false, android.icon=2130838811, android.text=null, android.progress=0, android.progressMax=0, android.appInfo=ApplicationInfo{8829c01 com.google.android.apps.maps}, android.contains.customView=true, android.showWhen=true, android.largeIcon=null, android.infoText=null, android.originatingUserId=0, android.progressIndeterminate=false, android.remoteInputHistory=null}]
 
Upvote 0

kolpolok

Member
Licensed User
Longtime User
I have used below code
B4X:
Dim jno As JavaObject = SBN.Notification
Dim extras As JavaObject = jno.GetField("extras")
extras.RunMethod("size", Null)
Log(extras)
Please help how to loop through all elements of a javaobject like SBN.Notification
 
Upvote 0

kolpolok

Member
Licensed User
Longtime User
log(jno)
(Notification) Notification(pri=2 contentView=com.google.android.apps.maps/0x7f0500b3 vibrate=null sound=null defaults=0x0 flags=0x6a color=0x00000000 groupKey=navigation_status_notification_group vis=PUBLIC)
 
Upvote 0
Top