Skip to content

Commit 37b2ed7

Browse files
committed
Use startForegroundService() on Android O
1 parent 7fdca70 commit 37b2ed7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/src/main/java/com/termux/tasker/FireReceiver.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Context;
55
import android.content.Intent;
66
import android.net.Uri;
7+
import android.os.Build;
78
import android.os.Bundle;
89
import android.util.Log;
910
import android.widget.Toast;
@@ -58,7 +59,13 @@ public void onReceive(final Context context, final Intent intent) {
5859
executeIntent.setClassName("com.termux", TERMUX_SERVICE);
5960
if (!inTerminal) executeIntent.putExtra("com.termux.execute.background", true);
6061
executeIntent.putExtra(PluginBundleManager.EXTRA_ARGUMENTS, list.toArray(new String[list.size()]));
61-
context.startService(executeIntent);
62+
63+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
64+
// https://developer.android.com/about/versions/oreo/background.html
65+
context.startForegroundService(executeIntent);
66+
} else {
67+
context.startService(executeIntent);
68+
}
6269
}
6370

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

0 commit comments

Comments
 (0)