Overview of Android im instant Messaging development

Source: Internet
Author: User
Tags live chat eventbus

The most successful instance of IM instant Messaging should be,,, this time IM is built on bmob, borrowing the service side and IM, Android SDK

Transfer:

Andorid Quick Start

Detailed Development documentation

Im Quick Start

Its document organization is not very good, I think basically is the three links are better, all the links from this page

Http://docs.bmob.cn/android/developdoc/index.html?menukey=develop_doc&key=develop_android

Then you have to look at the library document yourself, and you have to say that it's too simple to write. Fortunately there are demos and questions and answers, the answer is actually very fast.

SOURCE download

Quick Start related source download

Case tutorials and source code is the easiest way to get started, Bmob also prepared relevant case tutorials and source code, you are welcome to download and review.

For the convenience of everyone to better understand the Bmob SDK can do things, we also deliberately provide you with some source code, we can download, embed Bmob appkey, then package run.

Reading the source code is a good habit!!

Live chat case Source: https://github.com/bmob/BmobIMSDK4Android

Graphic Community Case Source: Https://git.oschina.net/v7/Wonderful This case is provided by the Ape Circle development team.

School side dishes Case Source: Https://github.com/bmob/Shop This case is a friend of the lake to provide.

Social sharing case Source: Https://github.com/bmob/bmob-android-social-share This is a diamond lock developer.

Third-party login case Source: Https://github.com/bmob/bmob-android-demo-thirdpartylogin includes third-party login and login to obtain user information source code

Because there was no development experience, so this development is still very difficult, see the source almost to my life.

I see of course is the real-time communication case source, this development mainly pay attention to such a few things

1.IM SDK, in fact, a lot of online use of the demo are older, but Bmob update relatively fast, so I suggest or read more, I look at the latest IM SDK in July 2016 to write, the new demo function is relatively simple, the main is the normal transmission of some messages, Here the main note two points, one is the message receiving mechanism, the message receiving mechanism has two, one is the global message receiving mechanism, shape as:

Bmobimmessagehandler

This is also illustrated in the IM rapid development documentation. There is also a local message receiving mechanism:

Implements Messagelisthandler
@Override
public void Onmessagereceive (list<messageevent> List) {
LOGGER.I ("Chat page received message:" + list.size ());
When registering a page message listener, a message (including offline messages) will be recalled when it arrives
for (int i=0;i<list.size (); i++) {
Addmessage2chat (List.get (i));
}
}

What is this, an activity? If the class is implements, the message sink function is overridden, and the Onmessagereceive function is executed when it is in the activity and has a message notification.

Another point to note is the message customization, because the Bmob encapsulated message type is relatively small, if you want to expand, you need to understand the message of the custom mechanism, these are in the IM rapid development documentation, such as the addition of Friends custom message class:

Package Cn.bmob.imdemo.bean;import Android.text.textutils;import Org.json.jsonobject;import cn.bmob.imdemo.Config; Import Cn.bmob.imdemo.db.newfriend;import Cn.bmob.newim.bean.bmobimextramessage;import Cn.bmob.newim.bean.bmobimmessage;import com.orhanobut.logger.logger;/** Add Friend Request * @author: Smile * @project: Addfriendmessage * @date: 2016-01-30-17:28 */public class Addfriendmessage extends bmobimextramessage{public AddFriend Message () {}/** bmobimmessage to Newfriend * @param MSG message * @return */public static newfriend convert (Bm        Obimmessage msg) {newfriend add =new newfriend ();        String content = Msg.getcontent ();        Add.setmsg (content);        Add.settime (Msg.getcreatetime ());        Add.setstatus (Config.status_verify_none);            try {String extra = Msg.getextra (); if (!                Textutils.isempty (extra)) {Jsonobject json =new jsonobject (extra);                String name = json.getstring ("name"); Add.setname (name);                String avatar = json.getstring ("Avatar");                Add.setavatar (avatar);            Add.setuid (json.getstring ("UID"));            }else{logger.i ("Addfriendmessage's Extra is empty");        }} catch (Exception e) {e.printstacktrace ();    } return add;    } @Override Public String Getmsgtype () {return ' add '; } @Override public Boolean istransient () {///is set to true, indicating that the message is transient, then it is not saved to the local db, the SDK is only responsible for sending out//set to False, the    will be saved to the database in the specified session return true; }}

  

2. Android Development Documentation

Because of the use of the Bmob server, so all my tables, everything is directly stored in the cloud, how to send messages to the cloud, how to read data from the cloud, this directly look at the previous development document. Are explained in detail, but hope that the library document can continue to improve.

3. Code structure

Due to the lack of familiarity with Android development, various components, various view (Listview, Recyclerview. ), the adapter's understanding takes a lot of time, basically, an activity class has an XML file, at least one, and then there is an adapter processing time event; XML, note that the nesting relationship is very complex, is an XML bar, there are many XML composition, finished there are many layout relationships. t.t

4. Event handling

The event handling here is mainly between activity and activity, startactivity, Startactivityforresult, and this can be seen Eventbus use detailed (a)--preliminary use Eventbus

This four to understand, there is nothing to read the demo.

Overview of Android im instant Messaging development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.