本文整理汇总了Java中io.rong.imkit.RongIM.connect方法的典型用法代码示例。如果您正苦于以下问题:Java RongIM.connect方法的具体用法?Java RongIM.connect怎么用?Java RongIM.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.rong.imkit.RongIM
的用法示例。
在下文中一共展示了RongIM.connect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import io.rong.imkit.RongIM; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splash);
context = this;
SharedPreferences sp = getSharedPreferences("config", MODE_PRIVATE);
String cacheToken = sp.getString("loginToken", "");
if (!TextUtils.isEmpty(cacheToken)) {
RongIM.connect(cacheToken, SealAppContext.getInstance().getConnectCallback());
handler.postDelayed(new Runnable() {
@Override
public void run() {
goToMain();
}
}, 800);
} else {
handler.postDelayed(new Runnable() {
@Override
public void run() {
goToLogin();
}
}, 800);
}
}
示例2: getPushMessage
import io.rong.imkit.RongIM; //导入方法依赖的package包/类
/**
* 得到不落地 push 消息
*/
private void getPushMessage() {
Intent intent = getIntent();
if (intent != null && intent.getData() != null && intent.getData().getScheme().equals("rong")) {
String path = intent.getData().getPath();
if (path.contains("push_message")) {
SharedPreferences sharedPreferences = getSharedPreferences("config", MODE_PRIVATE);
String cacheToken = sharedPreferences.getString("loginToken", "");
if (TextUtils.isEmpty(cacheToken)) {
startActivity(new Intent(MainActivity.this, LoginActivity.class));
} else {
if (!RongIM.getInstance().getCurrentConnectionStatus().equals(RongIMClient.ConnectionStatusListener.ConnectionStatus.CONNECTED)) {
LoadDialog.show(mContext);
RongIM.connect(cacheToken, new RongIMClient.ConnectCallback() {
@Override
public void onTokenIncorrect() {
LoadDialog.dismiss(mContext);
}
@Override
public void onSuccess(String s) {
LoadDialog.dismiss(mContext);
}
@Override
public void onError(RongIMClient.ErrorCode e) {
LoadDialog.dismiss(mContext);
}
});
}
}
}
}
}
示例3: doBusiness
import io.rong.imkit.RongIM; //导入方法依赖的package包/类
@Override
protected void doBusiness() {
toolbarTitle.setText("消息列表");
if (RongIMClient.getInstance().getCurrentConnectionStatus()
== RongIMClient.ConnectionStatusListener.ConnectionStatus.DISCONNECTED) {
String userId = getLoginUser();
if (TextUtils.isEmpty(userId)) {
return;
}
List<Configure> configureList = getConfigureList();
if (ListUtils.isEmpty(configureList)) {
return;
}
Configure configure = configureList.get(0);
if (configure == null) {
return;
}
RongIM.connect(configure.getToken(), new RongIMClient.ConnectCallback() {
@Override
public void onTokenIncorrect() {
LogUtils.d(TAG, "onTokenIncorrect: " + "Token错误!");
}
@Override
public void onSuccess(String s) {
LogUtils.d(TAG, "onSuccess: " + "连接成功" + s);
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
LogUtils.d(TAG, "onError: " + "融云服务器错误:" + errorCode);
}
});
}
}
示例4: connectRongIM
import io.rong.imkit.RongIM; //导入方法依赖的package包/类
public void connectRongIM() {
if (TextUtils.isEmpty(userId)) {
if (getView() == null) {
return;
}
getView().showMessage("获取当前登录用户失败,请重新登录!");
return;
}
List<Configure> configureList = getConfigureList();
final Configure configure;
if (ListUtils.isEmpty(configureList)) {
if (getView() == null) {
return;
}
getView().showMessage("获取Token失败,请重新登录!");
return;
}
configure = configureList.get(0);
final User user = configure.getUser();
RongIM.connect(configure.getToken(), new RongIMClient.ConnectCallback() {
@Override
public void onTokenIncorrect() {
getView().showMessage("Token不正确,请重新登录!");
}
@Override
public void onSuccess(String s) {
if (user == null) {
if (getView() == null) {
return;
}
getView().showMessage("未获取到用户信息,请重新登录!");
return;
}
RongIM.getInstance()
.setCurrentUserInfo(new UserInfo(user.getUser_id(), user.getTrueName(),
Uri.parse(Constants.PICTURE_URL + user.getHead_pic_thumb())));
RongIM.getInstance().setMessageAttachedUserInfo(true);
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
if (getView() == null) {
return;
}
getView().showMessage("连接即时聊天服务器出错!");
}
});
}