Custom Module
Custom module allows you to integrate custom actions in the dropdown menu of chat window. Such as displaying the profile of user with whom a connected user is chatting or any action related to the opened chat window.
To create a custom MQTT chat module, you need to add java class that extends moduleA abstract class.
For example the module below allows to display the profile of the user corresponding to the current discussion by clicking on the menu.
1
2
public class userProfile extends com.telifoun.mqttchat.modules.moduleA {
3
/**
4
*
5
* @param ctx
6
* @param Name
7
* @param Label
8
*/
9
public userProfile(android.content.Context ctx, String Name, String Label) {
10
super(ctx, Name, Label);
11
}
12
@Override
13
public void moduleMenuItemCLicked() {
14
/* lounch profile activity on menu item click */
15
Intent i = new Intent(getMessageActivity(), ProfileActivity.class);
16
i.putExtra("userId", getMessageActivity().getToUserid());
17
getMessageActivity().startActivity(i);
18
}
19
}
20
Copied!
Then add module to your Application class.
1
serProfile mProfile=new userProfile(getApplicationContext(),"User Profile","Go to Profile");
2
Mqttchat.getmInstance().getModules().add(mProfile);
Copied!
Last modified 8mo ago
Copy link