Skip to content

Commit

Permalink
debug foreground issue by adding thread sleep in starting forground
Browse files Browse the repository at this point in the history
  • Loading branch information
Ichchhie committed Mar 23, 2022
1 parent f204d58 commit a6482b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a6482b8

Please sign in to comment.