diff --git a/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/MapboxNavigation.java b/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/MapboxNavigation.java index 83a7824f..ff5ea36c 100644 --- a/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/MapboxNavigation.java +++ b/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/MapboxNavigation.java @@ -5,9 +5,7 @@ import android.content.Intent; import android.content.ServiceConnection; import android.os.Build; -import android.os.Handler; import android.os.IBinder; -import android.os.Looper; import android.util.Log; import androidx.annotation.NonNull; @@ -835,16 +833,7 @@ public void onServiceConnected(ComponentName name, IBinder service) { Log.d("NavigationService", "Connected to service."); NavigationService.LocalBinder binder = (NavigationService.LocalBinder) service; navigationService = binder.getService(); - new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - navigationService.startNavigation(MapboxNavigation.this); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); + navigationService.startNavigation(this); isBound = true; } diff --git a/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationService.java b/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationService.java index 6ee2c6af..8cddcd6b 100644 --- a/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationService.java +++ b/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationService.java @@ -133,17 +133,17 @@ private void startForegroundNotification(NavigationNotification navigationNotifi final Notification notification = navigationNotification.getNotification(); final int notificationId = navigationNotification.getNotificationId(); notification.flags = Notification.FLAG_FOREGROUND_SERVICE; -// new Handler(Looper.getMainLooper()).post(new Runnable() { -// public void run() { -// startForeground(notificationId, notification); -// try { -// Thread.sleep(10000); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } -// } -// }); - startForeground(notificationId, notification); + new Handler(Looper.getMainLooper()).post(new Runnable() { + public void run() { + startForeground(notificationId, notification); + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); +// startForeground(notificationId, notification); } class LocalBinder extends Binder {