Summary of problems in Android easeui 3.0 instant messaging

0. Needless to say about the registered account.

1. Create application and obtain appkey

0. Create an application

1. Fill in information

2. Get appkey

2. Integration

0. Create a new project first

1. Here we mainly introduce the use of ease UI to integrate the instant messaging function of Huanxin. You need to download the SDK

2. Import the ease UI into the project as a dependency, and then establish the dependency

3 possible problems after import:

three

This permission is reported as wrong. After consulting the official technology, the reply is that this permission can be removed. For specific permission information, refer to the permissions in the demo.

3.1 The V4 package conflict is caused by the V4 package contained in the easeui, but an error is reported after the V4 package of the project is deleted. The reason is that V7 package is included in the project, and V7 package contains V4, so an error will still be reported.

The error information is as follows:

At first, I thought it was the JDK, but after consulting the data, I found that it was a package conflict. Solution: delete V7 in the project, then delete V4 in ease UI, and then add V7 package in ease UI. So you won't report an error.

4. Environment information configuration:

4.0: in Android manifest Add the following permissions to the XML file:

4.1: configure ring information key

4.2 initialization: write the simplest here. Refer to the demo for other functions such as friend verification

4.3.0 in the use of easeui, baidu maps is involved. Here, you need to create an application on the official website of Baidu maps and apply for appkey: the specific configuration is as follows (you only need to fill in the appkey here and do not need to initialize):

4.3. 1: When sending pictures, you may have the function of viewing large pictures and maps. These activities are provided in ease UI. We only need to register in our own list file. The specific codes are as follows:

3. Use

Skip the login and registration functions on the document here. In this section, we will introduce the places where there may be pits.

Note: 0. The registration function generally needs to be implemented by the server; 1. When using initialization, the ease UI has the automatic login function by default. Note that if you need to turn off this function, add the following code in the initialization part:

0. Ease UI adapts to Android 6 0:

In the downloaded demo, find the runtimepermissions folder (see the figure for the specific path), and then add the code in mainactivity (see the figure)

Add the following code to mainactivity

1. In message listening, if you need to check whether you have come here, do not use toast to verify, because it belongs to a child thread in listening.

2. The avatar and user name used. It is recommended to store the URL of the avatar and the user's nickname in the local database, so that you don't have to go to the background to get it every time (if you get it from the background, it may flash). If the user information changes, you can ask the background to send a transparent message, and then update the data in the database.

3. The topping and de topping of messages can be realized by extending messages. In the ring message, each message can be attached with an extended message. We can add an attribute to the extended message, and then implement topping according to this attribute when setting the adapter. When sending messages, we should give messages in each topping session, The extended attribute is attached to all.

4. For the forbidden words of group chat, you can first judge your forbidden state when you enter to chat, and then ask the background to send a transparent message to solve this problem when you are forbidden or cancelled.

5. For setting the circular avatar, you need to use the custom view in the layout file to replace the ImageView in the easeui;

6. Customize the message list. If the last message is an expression, add this sentence to show the last expression.

Location:

7. Send yourself a message

8. Custom message items. If you need to share a QQ chat page, you need to define the layout of such items. Well, no, it should be two. One received and one sent.

Then, easeui provides an interface (easecustomchatrowprovider) for us to implement. The key codes are as follows:

8.0 first write the number of custom entries (in the required number * 2, one received and one sent)

Defines the types of messages received and sent

8.1 three methods to realize:

getCustomChatRowType

In this method, we can use the extended message of the message. We first judge the content of the extended message, and then load different layouts respectively.

To create different entries

The custom entry code is as follows (you can refer to the entry style provided by easeui, and the easechatrowpic. Java code is provided here)

Usage: in the activity where the fragment is located, set the properties of the chat page. The code is as follows:

Use custom entries

9. The startup mode of the chat interface uses single task. If the interface jumps repeatedly, a page Jump will appear.

10. After integrating the ease UI, a problem was found. Some versions of mobile phones may have a desktop icon and the program crashes. The solution is as follows:

Create an armeabi-v7a under LIBS and copy the so in armeabi in v7a, which is compatible with more versions of mobile phones.

11. It was found that the voice playback function on the chat page could not be used, and there was no click playback effect. I found the reason for a long time. It is found that the clicking avatar attribute is set before entering the chat fragment... What a pit. It took half a day..

Click event of message

Well, that's all for the ease UI section. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>