Infrastructure for Instant Messaging
Hi , i read several articles about Infrastructure for Instant Messaging for android . i created an app of news and i'd like integrate an instant messaging app inside the app , but i'd like know which is the best way to do it quickly with jabber for exemple .
what do you advise me ?
thank you advance for your response
Re: Infrastructure for Instant Messaging
Brace yourself for the awesomeness that is Intents. You have probably used intents for starting activities but they can do a lot more that this. Basically, an app like Jabber will tell the operating system it is capable of doing something. Your app then requests the operating system does something like sending an email or sms. It constructs a list of all the apps that can achieve this action and lets the user choose which app to use.
As a taster, here is some code to send an email:
String subject = "Hi there";
String message = "Java is cool.";
Intent sendIntent = new Intent( Intent.ACTION_SEND );
sendIntent.setType( "text/plain" );
sendIntent.putExtra( Intent.EXTRA_SUBJECT, subject );
sendIntent.putExtra( Intent.EXTRA_TEXT, message );
_main.startActivity( Intent.createChooser( sendIntent, "Email:" ) );
The putExtra() allows you to pass name/value pairs to the destination app. Read up on the list of standard extras in the intent documentation.