Skip to content

Commit

Permalink
Fix: Issue created by ekasetiawans#336
Browse files Browse the repository at this point in the history
  • Loading branch information
berkekbgz committed Aug 5, 2023
1 parent 83bc49c commit 6fedeed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ public int onStartCommand(Intent intent, int flags, int startId) {
@SuppressLint("WakelockTimeout")
private void runService() {
try {
if (isRunning.get() || (backgroundEngine != null && !backgroundEngine.getDartExecutor().isExecutingDart())) {
Log.v(TAG, "Service already running, using existing service");
return;
}

Log.v(TAG, "Starting flutter engine for background service");
getLock(getApplicationContext()).acquire();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
Expand Down Expand Up @@ -53,16 +54,18 @@ public static void remove(Context context) {

@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION_RESPAWN)){
if (intent.getAction().equals(ACTION_RESPAWN)) {
final Config config = new Config(context);
var isRunning = false
val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as am
for (service in manager.getRunningServices(Int.MAX_VALUE)) {
if (BackgroundService::class.java.name == service.service.className) {
isRunning = true
boolean isRunning = false;

ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (BackgroundService.class.getName().equals(service.service.getClassName())) {
isRunning = true;
}
}
if (!config.isManuallyStopped() && !isRunning) {

if (!config.isManuallyStopped() && !isRunning) {
if (config.isForeground()) {
ContextCompat.startForegroundService(context, new Intent(context, BackgroundService.class));
} else {
Expand Down

0 comments on commit 6fedeed

Please sign in to comment.