Skip to content

Instantly share code, notes, and snippets.

@SkyTreasure
Last active June 24, 2019 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SkyTreasure/0b984877c029b5f4a18ad26a6d4a0ccc to your computer and use it in GitHub Desktop.
Save SkyTreasure/0b984877c029b5f4a18ad26a6d4a0ccc to your computer and use it in GitHub Desktop.
HeadlessService
package com.yourpackagename;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import com.facebook.react.HeadlessJsTaskService;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
public class HeadlessService extends HeadlessJsTaskService {
@Override
protected @Nullable
HeadlessJsTaskConfig getTaskConfig(Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
return new HeadlessJsTaskConfig(
"BeaconScanTask",
Arguments.fromBundle(extras),
5000, // timeout for the task
true // optional: defines whether or not the task is allowed in foreground. Default is false
);
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment