/** * Is chat session active * * @param sessionId Session ID * @return Boolean */ private IChatSession isChatSessionActive(String sessionId) { try { return messagingApi.getChatSession(sessionId); } catch (Exception e) { return null; } }
@Override protected void onDestroy() { super.onDestroy(); if (rejoinChat != null) { rejoinChat.stop(); } if (restartChat != null) { restartChat.stop(); } if (messagingApi != null) { messagingApi.removeApiEventListener(this); messagingApi.disconnectApi(); } }
/** * Is RCS service available * * @return Boolean */ private boolean isServiceAvailable() { boolean result = false; try { if (apiEnabled && messagingApi.isImsConnected(getApplicationContext())) { result = true; } } catch (Exception e) { result = false; } return result; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set layout setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.messaging_chat_list); // Set UI title setTitle(getString(R.string.menu_chat_list)); // Instantiate messaging API RichMessaging.createInstance(getApplicationContext()); messagingApi = new MessagingApi(getApplicationContext()); messagingApi.addApiEventListener(this); messagingApi.connectApi(); // Set list adapter ListView view = (ListView) findViewById(android.R.id.list); TextView emptyView = (TextView) findViewById(android.R.id.empty); view.setEmptyView(emptyView); view.setAdapter(createChatListAdapter()); }
/** * Is group chat active * * @param chatId Chat ID * @return Boolean */ private IChatSession isGroupChatActive(String chatId) { try { List<IBinder> chatSessionsBinder = messagingApi.getGroupChatSessions(); for (IBinder binder : chatSessionsBinder) { IChatSession chatSession = IChatSession.Stub.asInterface(binder); if (chatSession.getChatID().equals(chatId)) { return chatSession; } } return null; } catch (Exception e) { return null; } }