Cloud IM development Preparation (Android)

Source: Internet
Author: User

Registered

First go to the cloud website to register a Development Account address here

Download

Then download the Cloud Development SDK address here

    • Demo source for the official sample demo, without modification, direct operation can successfully see the relevant features of the cloud

    • The SDK is divided into two parts: the Cloud Im Interface component (IMKITHT) and the cloud IM Communication capability Library (IMLIB)

Create an App

Go to the cloud developer platform to create an app where Android needs to be aware

    • app identity-package name here is the package name for the Android project, as the package name for the following code is Io.rong.imkit.demo
<manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="io.rong.imkit.demo">
    • Appkey-app Key Here is the value of the APP key that needs to be declared in the manifest file, the development phase uses the development environment (test environment), the development should be switched to the production environment (the online environment), simple examples such as the following
 <meta-data android:name="RONG_CLOUD_APP_KEY" android:value="e7x8xycsx6flq" />
Project configuration
    • Add a declaration to App_key

    • If you are developing with Imkit, modify the value of all its android:host to the package name of the development app

    • If you are developing with Android studio, remember to add references to so files

Writing code
    • Initialization, it is recommended to put it in the oncreate of application.
 RongIM.init(this);
    • Get token, need developer server side support, if only for testing development, can go to the Cloud developer platform Select API Debugging-User Service-Get token for debugging development

    • Connect the cloud, get token and connect to the cloud server

        //Here directly hardcode to token assignment, please replace it with your own token. String token ="mkmykqtsf7andinwafmnz7nxkilev3x0+ccrboxmtoapmvqjmathviwrepifq0gutu9jelqqsckv4ahfjcakgq==";//Connect to a cloud server. Rongim.connect (token,NewRongimclient.connectcallback () {@Override             Public void onsuccess(String s) {//The connection is processed successfully here. LOG.D ("Connect:","Login successfully."); }@Override             Public void OnError(ErrorCode ErrorCode) {//Handle connection errors here. LOG.D ("Connect:","Login failed."); }        });
    • When the server connection is successful, you can call the various chat interfaces of the cloud.

Cloud IM development Preparation (Android)

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.