androidx.core.app.JobIntentService Java Examples

The following examples show how to use androidx.core.app.JobIntentService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LeanplumJobStartReceiver.java    From Leanplum-Android-SDK with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    try {
        if (intent.getExtras() == null) {
            Log.w("Cannot enqueue work on JobIntentService, no extras in intent.");
            return;
        }

        String serviceName = intent.getStringExtra(LP_EXTRA_SERVICE_CLASS);
        int jobId = intent.getIntExtra(LP_EXTRA_JOB_ID, 0);

        Class service = Class.forName(serviceName);
        if (!JobIntentService.class.isAssignableFrom(service)) {
            Log.w("The service provided is not a type of JobIntentService.");
            return;
        }

        intent.setClass(context, service);

        JobIntentService.enqueueWork(context, service, jobId, intent);
    } catch (Exception e) {
        Util.handleException(e);
    }
}