9 Replies Latest reply on Apr 27, 2015 12:03 AM by ashish gupta

    Current state of aSmack (Smack for Android)

    Flow KeyContributor

      aSmack was initiated by Rene Treffer for the buddycloud project. The last available download from him on the aSmack project page on googlecode is from December 2010. Prior to that, the development has been moved to github. But the development stalled there. The last commit is from Aug 2010. This is when I forked the aSmack and Smack repositories on github and started to merge the changes introduced by Smack 3.2.0. I has also added the changes from the upstream. aSmack codebase is now in sync with Smack upstream development.

       

       

      Early alpha development versions of Smack 4.1 are able to run native on Android. Therefore making aSmack obsolete. They also come with support for XEP-198: Stream Management and can be found on maven central. You can read more about it in the

       

      Smack 4.1 Readme and Upgrade Guide

       

      if you want to try those.

        • Re: Current state of aSmack (Smack for Android)
          Tarik Bronze

          Hi Flow,

           

          I passed 1 week trying to understand this sentence in the README:

          "In order to work correctly on Android, you need to register Smack's

          XMPP Providers and Extensions manually and init some static code

          blocks before you doing any XMPP activty. Calling

          SmackAndroid.init(Context) (in org.jivesoftware.smack) will do this

          for you."

           

          But really it is difficult for me. Could you please help with a step by step TUTORIAL so that we could understand?

           

          What do you call context ? Are you refering to the Context of a main class activity ?

           

          The truth is that if you could give a simple working example I would be really greatful.

           

          Here is my code but I think I'm not getting it:

           

          ############################################

          public class MainActivity extends Activity {

                    public final static String EXTRA_MESSAGE = "com.example.rasaxe.MESSAGE";

                    private static Context context;

                    @Override

                    protected void onCreate(Bundle savedInstanceState) {

                              super.onCreate(savedInstanceState);

                              setContentView(R.layout.activity_main);

                              context = getApplicationContext();

                    }

           

           

              /*public static Context getAppContext() {

                  return context;

              }*/

           

                    @Override

                    public boolean onCreateOptionsMenu(Menu menu) {

                              // Inflate the menu; this adds items to the action bar if it is present.

                              getMenuInflater().inflate(R.menu.activity_main, menu);

                              return true;

                    }

           

                    /** Called when the user clicks the Send button */

                    public void sendMessage(View view) {

                        // Do something in response to button

                              Intent intent = new Intent(this, DisplayMessageActivity.class);

                              EditText editText = (EditText) findViewById(R.id.edit_message);

                        String message = editText.getText().toString();

                        intent.putExtra(EXTRA_MESSAGE, message);

           

           

                              SmackAndroid.init(context);

                        /*AndroidConnectionConfiguration config = null;

                        try {

                                        config = new AndroidConnectionConfiguration("jabber.org", 5222);

                              } catch (XMPPException e) {

                                        // TODO Auto-generated catch block

                                        e.printStackTrace();

                              }

                        Connection.DEBUG_ENABLED = true;

                        Connection conn2 = new XMPPConnection(config);

                        try {

           

                                        conn2.connect();

                                        conn2.login("rasaxe", "Tahranovitch1");

                              } catch (XMPPException e) {

                                        // TODO Auto-generated catch block

                                        e.printStackTrace();

                              }*/

                        startActivity(intent);

                    }

           

           

          }

          ################################

           

          Regards,

           

          Tarik

            • Current state of aSmack (Smack for Android)
              Flow KeyContributor

              The README mentions IIRC a few open-source Android apps. Studying their code should help you.

               

              The senctence really just means that you need to call SmackAndroid.init(Context) once. Ideally as soon as possible but at least before doing any XMPP activity i.e. Smack API calls. The type of context you use should not really matter, but I think that the application context is the best choice.

            • Re: Current state of aSmack (Smack for Android)
              JohnBe Bronze

              I need the smack lib in android and are very happy to found your nice jar, but i get a ClassNotFoundException for the org.jivesoftware.smackx.ServiceDiscoveryManager as soon as I try to init smack with SmackAndroid.init(getApplicationContext()); in my main activity.

              That kind of problem comes normaly with a wrong classpath configuration, but in android all you have to do is drop the jar in the libs folder... or so i thought.

              Do you have any suggestions to fix this problem?

               

              best regards

              • Re: Current state of aSmack (Smack for Android)
                Riddhipratim Sengupta Bronze

                Hi Flow,

                 

                The latest stable build for Smack is v.4.0.5.  Is it possible to port all the latest pure jars to be android compatible or optimized for android use.I will be more than happy to start a new project on github for Smack 4.0.5 android (aSmack).

                 


                Please do repost if you already have done something like that.

                • Re: Current state of aSmack (Smack for Android)
                  Zigma Bronze

                  smack-android 4.1.0 beta2 is available and BOSH protocol based smack-bosh in combination with jbosh 0.8.0