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