ChatFragment is the principal UI element which contains a chat list and message sending banner. In onCreate(), you must initialize:
Use IMbeeCore.getRealm() to get a Realm instance, remember to close this instance then!
publicclassMainActivityextendsAppCompatActivity {privateChatFragment chatFragment; @OverrideprotectedvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);IMbeeUI.initIMbeeUI(this);finalString CONVERSATION_ID ="...";// Once you get the conversation list, you can get the conversation with CONVERSATION_IDRealm realm =IMbeeCore.getRealm();Conversation conversation =ConversationList.getConversation(realm, CONVERSATION_ID); chatFragment =ChatFragment.newInstance(conversation);// Register a callback to be invoked when a button is clicked.chatFragment.setCallbacks(new ChatFragment.Callbacks() { @OverridepublicvoidonButtonClicked(Message message,ButtonContent buttonContent) {// It can be "url", "postback" ...if (buttonContent.buttonType.equals("url")) { // When it is a url buttonIntent browserIntent =newIntent(Intent.ACTION_VIEW,Uri.parse(buttonContent.payload));startActivity(browserIntent); } } @OverridepublicvoidonLinkClicked(String url) {Intent browserIntent =newIntent(Intent.ACTION_VIEW,Uri.parse(url));startActivity(browserIntent); } });getSupportFragmentManager().beginTransaction().add(R.id.chat_fragment, chatFragment).commit();realm.close(); }}
In the activity_main.xml resource, you should add a FrameLayout like this: