Skip to content

Commit

Permalink
Use startForegroundService() on Android O
Browse files Browse the repository at this point in the history
  • Loading branch information
fornwall committed Nov 2, 2017
1 parent 7fdca70 commit 37b2ed7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/src/main/java/com/termux/tasker/FireReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
Expand Down Expand Up @@ -58,7 +59,13 @@ public void onReceive(final Context context, final Intent intent) {
executeIntent.setClassName("com.termux", TERMUX_SERVICE);
if (!inTerminal) executeIntent.putExtra("com.termux.execute.background", true);
executeIntent.putExtra(PluginBundleManager.EXTRA_ARGUMENTS, list.toArray(new String[list.size()]));
context.startService(executeIntent);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// https://developer.android.com/about/versions/oreo/background.html
context.startForegroundService(executeIntent);
} else {
context.startService(executeIntent);
}
}

/** Ensure readable and executable file if user forgot to do so. */
Expand Down

0 comments on commit 37b2ed7

Please sign in to comment.