Android 在其他界面里进行获取会话信息,查询好友 和群聊

jacc 6月前 113

代码1: 
List<Conversation.ConversationType> types = Arrays.asList(Conversation.ConversationType.Single,Conversation.ConversationType.Group);
                 List<Integer> lines = Arrays.asList(0);
                ConversationListViewModel  conversationListViewModel = new ViewModelProvider((ViewModelStoreOwner) this, new ConversationListViewModelFactory(types, lines))
                        .get(ConversationListViewModel.class);
                conversationListViewModel.conversationListLiveData().observe((LifecycleOwner) this, conversationInfos -> {

                });

            代码2:
               List<Conversation.ConversationType> types = Arrays.asList(Conversation.ConversationType.Single,Conversation.ConversationType.Group);
            List<Integer> lines = Arrays.asList(0);
            ChatManager.Instance().getWorkHandler().post(new Runnable() {
                @Override
                public void run() {
                    ChatManager.Instance().getConversationListAsync(types, lines, new GetConversationListCallback() {
                        @Override
                        public void onSuccess(List<ConversationInfo> conversationInfos) {

                        }

                        @Override
                        public void onFail(int errorCode) {

                        }
                    });
                }
            });
            都无法获取到数据
最新回复 (1)
  • x86 6月前
    引用 2
    第二种方法,肯定是没问题的,如果有问题,看看是否正常连上 im
返回