Android背景Runnable无法在旧设备上运行

时间:2017-09-13 19:29:40

标签: android google-cloud-messaging intentservice android-intentservice

我在IntentService

内启动时运行了以下内容
threadManager.postBackgroundRunnableDelayed(() -> {
            try {
                // Calling getToken and getId must be on separate thread. Otherwise, it blocks UI thread.
                String token = instanceID.getToken(SENDER_ID, GoogleCloudMessaging.INSTANCE_ID_SCOPE);
                String id = instanceID.getId();
                Timber.d("id: " + id);
                Timber.d("token: " + token);
                lazyRestQueue.get().sendGcmToken(new GcmPushRequest(id, token), getSendGcmTokenCallback());
                setupAnalytics(token);
            } catch (IOException e) {
                Timber.e(e, "Exception during registration");
                Crashlytics.logException(e);
                setHasToken(false);
            } catch (RuntimeException e) {
                // This will be thrown if Localytics was not properly setup
                Timber.e(e, "Exception during registration");
            }
        });

当我在API 18以下的任何地方运行它时会导致应用关闭(不会奇怪地崩溃,只是关闭)

有人可以给我这方面的建议吗?我知道这可能与服务有关或者时间不正确

0 个答案:

没有答案