没有连接到Quickbox

时间:2015-02-08 16:29:10

标签: android quickblox

我正在尝试使用Quickblox创建一个会话,但我从来没有得到Quickblox的答案。 onConnect或onError未触发。我正在从模拟器进行测试。

我的代码:

package com.example.jdc.testjdclogin2;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.quickblox.auth.QBAuth;
import com.quickblox.auth.model.QBSession;
import com.quickblox.core.QBCallback;
import com.quickblox.core.QBEntityCallbackImpl;
import com.quickblox.core.QBSettings;
import com.quickblox.core.result.Result;
import com.quickblox.users.QBUsers;
import com.quickblox.users.model.QBUser;

import java.util.List;


public class MainActivity extends ActionBarActivity  {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    public void LoginClicked(View view){
        QBUser user = new QBUser();
        user.setEmail("testuser@gmail.com");
        user.setPassword("Abcd_1234");
        QBSettings.getInstance().setApplicationId("19425");
        QBSettings.getInstance().setAuthorizationKey("4DuqMR78cuBdMu9");
        QBSettings.getInstance().setAuthorizationSecret("Tc8Ukxq-XUBLYz4");
        QBAuth.createSession(new QBEntityCallbackImpl<QBSession>() {

            @Override
            public void onSuccess(QBSession session, Bundle params) {
                // You have successfully created the session
                //
                // Now you can use QuickBlox API!
                Log.i("Connection","session succeeded");
            }

            @Override
            public void onError(List<String> errors) {
                Log.i("Connection","session not succeeded");
            }
        });
        QBUsers.signIn(user, new QBEntityCallbackImpl<QBUser>() {
            @Override
            public void onSuccess(QBUser user, Bundle params) {
                Log.i("Connection","login succeeded");
            }

            @Override
            public void onError(List<String> errors) {
                Log.i("Connection","login not succeeded");
            }
        });

        Log.i("Connection","End of procedure");

    }


}
在Logcat中,我看到了对quickblox的调用但从未得到答案。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

找到用户=&gt;忘了添加使用互联网的权限