Guys, there is a task, I do not know how to approach. In the override onHandleIntent method there is a try catch , in which I need to shove the output of AlertDialog , I don’t know how to do this correctly, since there is no interface here (+ you’ll have to knock on the activation)?
Class code
class GcmRegistrationIntentService : IntentService("GcmRegistrationIntentService") { override fun onHandleIntent(intent: Intent?) { try { val gcmSenderId = FlavorSettings.gcmSenderId val systemToken = if (gcmSenderId.isEmpty()) gcmSenderId else InstanceID.getInstance(this).getToken(gcmSenderId, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null) if (PreferenceRepository.gcmToken != systemToken) { PreferenceRepository.gcmToken = systemToken if (UserSession.isUserSignedIn() && ProfilesRepository.lastProfile() != null) { JobManager.scheduleAutoSync() } } } catch (e: Exception) { e.log() } } }
AlertDialogfrom theIntentServiceit must have the typeTYPE_SYSTEM_ALERT, and for this you need the appropriate perm. Describe your usage scenario. Perhaps you do not need a dialogue and something else is suitable, for example, notification. - eugeneek