0

我想在我的音频调用代码中实现 mesibo 实时 API,但这里提供的代码仍然有问题,随机数给出空指针。这里犯了什么错误。

  Mesibo api = Mesibo.getInstance();
                    api.init(getApplicationContext());

                    // set path for storing DB and messaging files
                    Mesibo.setPath(Environment.getExternalStorageDirectory().getAbsolutePath());

                    // add listener
                    Mesibo.addListener(this);

                    // set access token
                    if(0 != Mesibo.setAccessToken(access_token)) {
//                        return false;
                    }

                    // set database after setting access token so that it's associated with the user
                    Mesibo.setDatabase("mesibo.db", 0);

                    // Now start mesibo
                    if(0 != Mesibo.start()) {
//                        return false;
                    }
                    Mesibo.UserProfile mProfile = new Mesibo.UserProfile();
                    mProfile.name = "user_name";
                    mProfile.address = "xyz";
4

1 回答 1

0

发布平台的日志和详细信息。你为什么评论 - “return false”?你用的是模拟器还是手机?

您可能在 setAccessToken 方法中传递了错误的令牌,因此 mesibo 没有初始化。任何尝试在未初始化的情况下使用 Mesibo 函数都可能导致崩溃。检查 Mesibo_onConnectionStatus 侦听器中的状态值。

https://mesibo.com/documentation/tutorials/get-started/android/

或在此处下载第一个应用程序

https://github.com/mesibo/samples/tree/master/android

于 2020-12-17T13:44:02.887 回答