【问题标题】:Quickblox create session being called through an intent service通过意图服务调用 Quickblox 创建会话
【发布时间】:2015-10-20 14:07:26
【问题描述】:

我正在尝试使用AlarmManager 安排Alarm,它尝试每两小时重新创建一次QuickBlox 会话。我正在通过AlarmManager 在后台调用IntentService

以下是崩溃的代码:

protected void onHandleIntent(Intent intent)
{
    String APP_ID = "xxxx";
    String AUTH_KEY = "xxxx";
    String AUTH_SECRET = "xxxx";
    QBSettings.getInstance().fastConfigInit(APP_ID, AUTH_KEY,AUTH_SECRET);
    if (!QBChatService.isInitialized()){
        QBChatService.init(getApplicationContext());
    }

    ChatService.getInstance().chatCreateWriteSessionWithoutPlay(getApplicationContext());}

chatCreateWriteSession的定义如下:

public void chatCreateWriteSessionWithoutPlay(final Context ctx) {
        chatService = QBChatService.getInstance();
        // Create QB user
        final QBUser user = new QBUser();

        user.setLogin(AppController.getInstance().getCHAT_ID());
        user.setPassword(AppController.getInstance().getCHAT_PASSWORD());
        QBAuth.createSession(user, new QBEntityCallbackImpl<QBSession>() {
            @Override
            public void onSuccess(QBSession session, Bundle args) {

            }

            @Override
            public void onError(List<String> errors) {

            }
        });
    }

【问题讨论】:

    标签: android quickblox intentservice android-intentservice


    【解决方案1】:

    所有在 QBEntityCallback 中返回结果的方法都在主 Ui 线程上执行。只需使用同步类型的方法,例如 QBSession session= QBAuth.createSession(QBUser user) 在 android 服务启动的同一线程上返回结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-22
      • 1970-01-01
      • 2012-09-16
      • 2011-11-06
      相关资源
      最近更新 更多