本文整理汇总了Java中io.rong.imkit.RongIM类的典型用法代码示例。如果您正苦于以下问题:Java RongIM类的具体用法?Java RongIM怎么用?Java RongIM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RongIM类属于io.rong.imkit包,在下文中一共展示了RongIM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDestroy
import io.rong.imkit.RongIM; //导入依赖的package包/类
@Override
protected void onDestroy() {
super.onDestroy();
if (localBroadcastManager != null) {
localBroadcastManager.unregisterReceiver(mainReceiver);
}
RongIM.getInstance().removeUnReadMessageCountChangedObserver(new IUnReadMessageObserver() {
@Override
public void onCountChanged(int i) {
}
});
if (RongIM.getInstance().getCurrentConnectionStatus()
== RongIMClient.ConnectionStatusListener.ConnectionStatus.CONNECTED) {
RongIM.getInstance().disconnect();
}
}
示例2: onSuccess
import io.rong.imkit.RongIM; //导入依赖的package包/类
@Override
public void onSuccess(int requestCode, Object result) {
if (result != null) {
GetGroupMemberResponse res = (GetGroupMemberResponse) result;
if (res.getCode() == 200) {
List<GetGroupMemberResponse.ResultEntity> mGroupMember = res.getResult();
for (GetGroupMemberResponse.ResultEntity g : mGroupMember) {
if (g.getUser().getId().equals(userId)) {
if (RongIM.getInstance() != null && RongIM.getInstance().getRongIMClient() != null) {
RongIM.getInstance().refreshGroupUserInfoCache(new GroupUserInfo(groupId, userId, g.getDisplayName()));
setGroupUserInfo(new GroupUserInfo(groupId, userId, g.getDisplayName()));
}
}
}
}
}
}
示例3: initListener
import io.rong.imkit.RongIM; //导入依赖的package包/类
/**
* init 后就能设置的监听
*/
private void initListener() {
RongIM.setConversationBehaviorListener(this);//设置会话界面操作的监听器。
RongIM.setConversationListBehaviorListener(this);//会话列表界面操作的监听器
RongIM.setConnectionStatusListener(this);//用户状态 例如 异地登录
RongIM.setUserInfoProvider(this, true);//获取用户信息
RongIM.setGroupInfoProvider(this, true);
RongIM.setLocationProvider(this);//设置地理位置提供者,不用位置的同学可以注掉此行代码
setInputProvider();
//setUserInfoEngineListener();//移到SealUserInfoManager
setReadReceiptConversationType();
RongIM.getInstance().enableNewComingMessageIcon(true);//设置会话界面未读新消息是否展示 注:未读新消息大于1条即展示
RongIM.getInstance().enableUnreadMessageIcon(true);//设置会话界面历史消息是否展示 注:历史消息大于10条即展示
BroadcastManager.getInstance(mContext).addAction(SealConst.EXIT, new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
quit(false);
}
});
}
示例4: setInputProvider
import io.rong.imkit.RongIM; //导入依赖的package包/类
private void setInputProvider() {
RongIM.setOnReceiveMessageListener(this);//设置接收消息的监听器。
List<IExtensionModule> moduleList = RongExtensionManager.getInstance().getExtensionModules();
IExtensionModule defaultModule = null;
if (moduleList != null) {
for (IExtensionModule module : moduleList) {
if (module instanceof DefaultExtensionModule) {
defaultModule = module;
break;
}
}
if (defaultModule != null) {
RongExtensionManager.getInstance().unregisterExtensionModule(defaultModule);
RongExtensionManager.getInstance().registerExtensionModule(new SealExtensionModule());
}
}
}
示例5: onConversationClick
import io.rong.imkit.RongIM; //导入依赖的package包/类
@Override
public boolean onConversationClick(Context context, View view, UIConversation uiConversation) {
MessageContent messageContent = uiConversation.getMessageContent();
if (messageContent instanceof ContactNotificationMessage) {
ContactNotificationMessage contactNotificationMessage = (ContactNotificationMessage) messageContent;
if (contactNotificationMessage.getOperation().equals("AcceptResponse")) {
// 被加方同意请求后
if (contactNotificationMessage.getExtra() != null) {
ContactNotificationMessageData bean = null;
try {
bean = JsonMananger.jsonToBean(contactNotificationMessage.getExtra(), ContactNotificationMessageData.class);
} catch (Exception e) {
e.printStackTrace();
}
RongIM.getInstance().startPrivateChat(context, uiConversation.getConversationSenderId(), bean.getSourceUserNickname());
}
} else {
context.startActivity(new Intent(context, NewFriendListActivity.class));
}
return true;
}
return false;
}
示例6: quit
import io.rong.imkit.RongIM; //导入依赖的package包/类
private void quit(boolean isKicked) {
Log.d(TAG, "quit isKicked " + isKicked);
SharedPreferences.Editor editor = mContext.getSharedPreferences("config", Context.MODE_PRIVATE).edit();
if (!isKicked) {
editor.putBoolean("exit", true);
}
editor.putString("loginToken", "");
editor.putString(SealConst.SEALTALK_LOGIN_ID, "");
editor.putInt("getAllUserInfoState", 0);
editor.apply();
/*//这些数据清除操作之前一直是在login界面,因为app的数据库改为按照userID存储,退出登录时先直接删除
//这种方式是很不友好的方式,未来需要修改同app server的数据同步方式
//SealUserInfoManager.getInstance().deleteAllUserInfo();*/
SealUserInfoManager.getInstance().closeDB();
RongIM.getInstance().logout();
Intent loginActivityIntent = new Intent();
loginActivityIntent.setClass(mContext, LoginActivity.class);
loginActivityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
if (isKicked) {
loginActivityIntent.putExtra("kickedByOtherClient", true);
}
mContext.startActivity(loginActivityIntent);
}
示例7: setConverstionNotif
import io.rong.imkit.RongIM; //导入依赖的package包/类
public static void setConverstionNotif(final Context context, Conversation.ConversationType conversationType, String targetId, boolean state) {
Conversation.ConversationNotificationStatus cns;
if (state) {
cns = Conversation.ConversationNotificationStatus.DO_NOT_DISTURB;
} else {
cns = Conversation.ConversationNotificationStatus.NOTIFY;
}
RongIM.getInstance().setConversationNotificationStatus(conversationType, targetId, cns, new RongIMClient.ResultCallback<Conversation.ConversationNotificationStatus>() {
@Override
public void onSuccess(Conversation.ConversationNotificationStatus conversationNotificationStatus) {
if (conversationNotificationStatus == Conversation.ConversationNotificationStatus.DO_NOT_DISTURB) {
// NToast.shortToast(context, "设置免打扰成功");
} else if (conversationNotificationStatus == Conversation.ConversationNotificationStatus.NOTIFY) {
// NToast.shortToast(context, "取消免打扰成功");
}
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
NToast.shortToast(context, "设置失败");
}
});
}
示例8: onClick
import io.rong.imkit.RongIM; //导入依赖的package包/类
@Override
public void onClick(View v) {
if (chatroomList == null || chatroomList.get(0) == null) {
NToast.shortToast(getActivity(), getString(R.string.join_chat_room_error_toast));
return;
}
switch (v.getId()) {
case R.id.def_chatroom1:
RongIM.getInstance().startConversation(getActivity(), Conversation.ConversationType.CHATROOM, chatroomList.get(0).getId(), "聊天室 I");
break;
case R.id.def_chatroom2:
RongIM.getInstance().startConversation(getActivity(), Conversation.ConversationType.CHATROOM, chatroomList.get(1).getId(), "聊天室 II");
break;
case R.id.def_chatroom3:
RongIM.getInstance().startConversation(getActivity(), Conversation.ConversationType.CHATROOM, chatroomList.get(2).getId(), "聊天室 III");
break;
case R.id.def_chatroom4:
RongIM.getInstance().startConversation(getActivity(), Conversation.ConversationType.CHATROOM, chatroomList.get(3).getId(), "聊天室 IV");
break;
}
}
示例9: 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);
}
}
示例10: initBlackListStatusView
import io.rong.imkit.RongIM; //导入依赖的package包/类
private void initBlackListStatusView() {
if (mIsFriendsRelationship) {
Button rightButton = getHeadRightButton();
rightButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.main_activity_contact_more));
rightButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
RongIM.getInstance().getBlacklistStatus(mFriend.getUserId(), new RongIMClient.ResultCallback<RongIMClient.BlacklistStatus>() {
@Override
public void onSuccess(RongIMClient.BlacklistStatus blacklistStatus) {
SinglePopWindow morePopWindow = new SinglePopWindow(UserDetailActivity.this, mFriend, blacklistStatus);
morePopWindow.showPopupWindow(v);
}
@Override
public void onError(RongIMClient.ErrorCode e) {
}
});
}
});
}
}
示例11: setAppPublicServiceActionBar
import io.rong.imkit.RongIM; //导入依赖的package包/类
/**
* 设置应用公众服务界面 ActionBar
*/
private void setAppPublicServiceActionBar(String targetId) {
if (targetId == null)
return;
RongIM.getInstance().getPublicServiceProfile(Conversation.PublicServiceType.APP_PUBLIC_SERVICE
, targetId, new RongIMClient.ResultCallback<PublicServiceProfile>() {
@Override
public void onSuccess(PublicServiceProfile publicServiceProfile) {
setTitle(publicServiceProfile.getName());
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
}
});
}
示例12: onDragOut
import io.rong.imkit.RongIM; //导入依赖的package包/类
@Override
public void onDragOut() {
mUnreadNumView.setVisibility(View.GONE);
NToast.shortToast(mContext, getString(R.string.clear_success));
RongIM.getInstance().getConversationList(new RongIMClient.ResultCallback<List<Conversation>>() {
@Override
public void onSuccess(List<Conversation> conversations) {
if (conversations != null && conversations.size() > 0) {
for (Conversation c : conversations) {
RongIM.getInstance().clearMessagesUnreadStatus(c.getConversationType(), c.getTargetId(), null);
}
}
}
@Override
public void onError(RongIMClient.ErrorCode e) {
}
}, mConversationsTypes);
}
示例13: onCreate
import io.rong.imkit.RongIM; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sp = getSharedPreferences("config", MODE_PRIVATE);
mDialog = new LoadingDialog(this);
Intent intent = getIntent();
//push
if (intent.getData().getScheme().equals("rong") && intent.getData().getQueryParameter("push") != null) {
//通过intent.getData().getQueryParameter("push") 为true,判断是否是push消息
if (intent.getData().getQueryParameter("push").equals("true")) {
enterActivity();
}
} else {//通知过来
//程序切到后台,收到消息后点击进入,会执行这里
if (RongIM.getInstance().getCurrentConnectionStatus().equals(RongIMClient.ConnectionStatusListener.ConnectionStatus.DISCONNECTED)) {
enterActivity();
} else {
startActivity(new Intent(ConversationListActivity.this, MainActivity.class));
finish();
}
}
}
示例14: setPublicServiceActionBar
import io.rong.imkit.RongIM; //导入依赖的package包/类
/**
* 设置公共服务号 ActionBar
*/
private void setPublicServiceActionBar(String targetId) {
if (targetId == null)
return;
RongIM.getInstance().getPublicServiceProfile(Conversation.PublicServiceType.PUBLIC_SERVICE
, targetId, new RongIMClient.ResultCallback<PublicServiceProfile>() {
@Override
public void onSuccess(PublicServiceProfile publicServiceProfile) {
setTitle(publicServiceProfile.getName());
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
}
});
}
示例15: getConversations
import io.rong.imkit.RongIM; //导入依赖的package包/类
private void getConversations() {
final Conversation.ConversationType[] conversationTypes = {
Conversation.ConversationType.PRIVATE,
Conversation.ConversationType.GROUP,
};
if (RongIM.getInstance().getCurrentConnectionStatus().equals(RongIMClient.ConnectionStatusListener.ConnectionStatus.CONNECTED)) {
RongIM.getInstance().getConversationList(new RongIMClient.ResultCallback<List<Conversation>>() {
@Override
public void onSuccess(List<Conversation> conversations) {
conversationsList = conversations;
getGroups();
}
@Override
public void onError(RongIMClient.ErrorCode e) {
}
}, conversationTypes);
}
}