Question about android sample application called 'chat'

asked 2015-01-01 04:57:49 -0700

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.


There is AllJoynService.java file in sample chat application.

In AllJoynService.java, ChatService class is defined as a follow:

  class ChatService implements ChatInterface, BusObject {

      public void Chat(String str) throws BusException {                                                                                              

And Details about 'public void Chat(String str)' is defined as a follow:

@BusSignalHandler(iface = "org.alljoyn.bus.samples.chat", signal = "Chat")
public void Chat(String string) {

    String uniqueName = mBus.getUniqueName();
    MessageContext ctx = mBus.getMessageContext();
    Log.i(TAG, "Chat(): use sessionId is " + mUseSessionId);
    Log.i(TAG, "Chat(): message sessionId is " + ctx.sessionId);

    if (ctx.sender.equals(uniqueName)) {
        Log.i(TAG, "Chat(): dropped our own signal received on session " + ctx.sessionId);

    if (mJoinedToSelf == false && ctx.sessionId == mHostSessionId) {
        Log.i(TAG, "Chat(): dropped signal received on hosted session " + ctx.sessionId + " when not joined-to-self");

    String nickname = ctx.sender;
    nickname = nickname.substring(nickname.length()-10, nickname.length());

    Log.i(TAG, "Chat(): signal " + string + " received from nickname " + nickname);
    mChatApplication.newRemoteUserMessage(nickname, string);

Can i remove aforementioned parts ( 'class ChatService' and 'public void Chat(String string)') from AllJoynService.java

and implement them as external class such as Chatservice.java ?

I want to hide them ('class ChatService' and 'public void Chat(String string)') from source code and make it

as JAR file.

is it possible?

Best regards

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-01-12 14:34:03 -0700

Nikhil Dabhade gravatar image

Hi poka_poka,

As I understand it as long as you maintain the same package name for the new class ChatService.java and make sure that the class ChatService implements both ChatInterface and BusObject you should be able to put this functionality in a separate JAR file. You would however would have to make sure that your manifest file loads the JAR that contains ChatService before you want to use it.


edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-01-01 04:57:49 -0700

Seen: 68 times

Last updated: Jan 12 '15