2
public class RegistrationIntentService extends JobIntentService {


private static final String TAG = "RegIntentService";
private static final String[] TOPICS = {"global"};
private static Context context1;
private String SENDER_ID;
private AppActivity appActivityContext;
private SharedPreferences.Editor editor;


public RegistrationIntentService() {
    super();
}

@Override
protected void onHandleWork(@NonNull Intent intent) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);


    try {


        sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply();
        // [END register_for_gcm]
    } catch (Exception e) {
        Log.d(TAG, "Failed to complete token refresh", e);
        // If an exception happens while fetching the new token or updating our registration data
        // on a third-party server, this ensures that we'll attempt the update at a later time.
        sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false).apply();
    }
    // Notify UI that registration has completed, so the progress indicator can be hidden.
    Intent registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE);
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);

}
...
}

I implemented jobintentservice but it doesnot work. Only super() inside the default constructor gets called. OnHandleWork is not called Works fine on android version below 8

Shubham Goel
  • 1,962
  • 17
  • 25
  • 1
    Did you add android:permission="android.permission.BIND_JOB_SERVICE" to the in the manifest? – Alex Mar 16 '18 at 07:12

0 Answers0