AnsweredAssumed Answered

MessageTypeFilter (org.jivesoftware.smack.packet.Message.Type) has private access in org.jivesoftware.smack.filter.MessageTypeFilter

Question asked by Mudassar on Oct 5, 2015
Latest reply on Oct 26, 2015 by Mudassar

I am working on Android XMPP client and trying to recieve message from ejabberd server. The Android-Studio-IDE shows error "MessageTypeFilter (org.jivesoftware.smack.packet.Message.Type) has private access in org.jivesoftware.smack.filter.MessageTypeFilter" on following line of code.

PacketFilter filter = new MessageTypeFilter(Message.Type.chat)

Complete code is

     XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
     configBuilder.setUsernameAndPassword("X@X.com", "XXX");
   //configBuilder.setResource("test");
     configBuilder.setPort(5222);
     configBuilder
.setCustomSSLContext(context);
     configBuilder
.setDebuggerEnabled(true);
//configBuilder.setSocketFactory(SSLSocketFactory.getDefault());
     configBuilder
.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
     configBuilder
.setHost("X.X.X.X");
     configBuilder
.setServiceName("X.com");  
     SASLMechanism mechanism = new SASLPlainMechanism();
     SASLAuthentication.registerSASLMechanism(mechanism);
     SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");
     SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5");
     SASLAuthentication.unBlacklistSASLMechanism("PLAIN");  

     final XMPPTCPConnection connection = new XMPPTCPConnection(configBuilder.build()); 

     try
{ 
          connection
.connect();
          Log.i("App1-conn","CONENCTION WORKS");
          connection
.login(); 
     }
     final XMPPTCPConnection finalCon = connection;
     Button sendMEssage  = (Button)findViewById(R.id.button_sendMEssage);
     sendMEssage
.setOnClickListener(new View.OnClickListener() {
           @Override public void onClick(View v) { 
          EditText msgtxt = (EditText)       findViewById(R.id.editText_message);
          Message message = new Message("Y@X.com");
          message
.addBody("App1 Eng", msgtxt.getText().toString());
          try {
               finalCon
.sendPacket(message);
          } catch (SmackException.NotConnectedException e) {
               Log.i("App1 Send ", "Packet Sending Failed");
               e
.printStackTrace();
          }
          Log.i("App1 Message Sent", "MEssage Sent"); 
         
PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
          connection.addAsyncPacketListener(new PacketListener() {
         
          @Override
          public void processPacket(Stanza packet) throws SmackException.NotConnectedException {
          }
      } , filter);

GRADLE FILE

compile "org.igniterealtime.smack:smack-android:4.1.0-rc1" // Optional for XMPPTCPConnection 
compile
"org.igniterealtime.smack:smack-tcp:4.1.0-rc1" // Optional for XMPP-IM (RFC 6121) support (Roster, Threaded Chats, …)
compile "org.igniterealtime.smack:smack-im:4.1.0-rc1" // Optional for XMPP extensions support
compile
"org.igniterealtime.smack:smack-extensions:4.1.0-rc1"
compile
"org.igniterealtime.smack:smack-sasl-provided:4.1.0-rc1"

Outcomes