diff --git a/docs/headless-js-android.md b/docs/headless-js-android.md index d4ec452583b..8ca7bd2ff5a 100644 --- a/docs/headless-js-android.md +++ b/docs/headless-js-android.md @@ -114,7 +114,7 @@ Bundle bundle = new Bundle(); bundle.putString("foo", "bar"); service.putExtras(bundle); -getApplicationContext().startService(service); +getApplicationContext().startForegroundService(service); ``` @@ -128,7 +128,7 @@ bundle.putString("foo", "bar") service.putExtras(bundle) -applicationContext.startService(service) +applicationContext.startForegroundService(service) ``` @@ -244,7 +244,7 @@ public class NetworkChangeReceiver extends BroadcastReceiver { boolean hasInternet = isNetworkAvailable(context); Intent serviceIntent = new Intent(context, MyTaskService.class); serviceIntent.putExtra("hasInternet", hasInternet); - context.startService(serviceIntent); + context.startForegroundService(serviceIntent); HeadlessJsTaskService.acquireWakeLockNow(context); } } @@ -327,7 +327,7 @@ class NetworkChangeReceiver : BroadcastReceiver() { val hasInternet = isNetworkAvailable(context) val serviceIntent = Intent(context, MyTaskService::class.java) serviceIntent.putExtra("hasInternet", hasInternet) - context.startService(serviceIntent) + context.startForegroundService(serviceIntent) HeadlessJsTaskService.acquireWakeLockNow(context) } } diff --git a/website/versioned_docs/version-0.74/headless-js-android.md b/website/versioned_docs/version-0.74/headless-js-android.md index d4ec452583b..8ca7bd2ff5a 100644 --- a/website/versioned_docs/version-0.74/headless-js-android.md +++ b/website/versioned_docs/version-0.74/headless-js-android.md @@ -114,7 +114,7 @@ Bundle bundle = new Bundle(); bundle.putString("foo", "bar"); service.putExtras(bundle); -getApplicationContext().startService(service); +getApplicationContext().startForegroundService(service); ``` @@ -128,7 +128,7 @@ bundle.putString("foo", "bar") service.putExtras(bundle) -applicationContext.startService(service) +applicationContext.startForegroundService(service) ``` @@ -244,7 +244,7 @@ public class NetworkChangeReceiver extends BroadcastReceiver { boolean hasInternet = isNetworkAvailable(context); Intent serviceIntent = new Intent(context, MyTaskService.class); serviceIntent.putExtra("hasInternet", hasInternet); - context.startService(serviceIntent); + context.startForegroundService(serviceIntent); HeadlessJsTaskService.acquireWakeLockNow(context); } } @@ -327,7 +327,7 @@ class NetworkChangeReceiver : BroadcastReceiver() { val hasInternet = isNetworkAvailable(context) val serviceIntent = Intent(context, MyTaskService::class.java) serviceIntent.putExtra("hasInternet", hasInternet) - context.startService(serviceIntent) + context.startForegroundService(serviceIntent) HeadlessJsTaskService.acquireWakeLockNow(context) } }