Android borrowing QQ open platform, simple to achieve contact customer service function

Source: Internet
Author: User

Company to do the e-commerce app, now to join the contact customer service function, at first thinking is to do an instant chat system, did not do before, the two days began to evil, then the demand changed, to call QQ open platform, do a temporary session on the line, which saves a lot of strength, also do not need to go to the component service end.

Steps:

1. Refer to the QQ SDK source code file.

Create a project and copy the Open-sdk.jar file and the Mta_sdk_x.x.x.jar file to the Libs (or LIB) directory, as shown in:

Select Open-sdk.jar and mta_sdk_x.x.x.ja, select Build path from the right-click menu, select Add to build Path


2. Add the configuration required by the SDK to the androidmanifest of the application;

Add the following configuration under the <application> node of the application's androidmanifest.xml add configuration ( Note: No configuration will cause the API not to be called)

<uses-permission android:name= "Android.permission.INTERNET"/><uses-permission android:name= " Android.permission.ACCESS_NETWORK_STATE "/><application><activity android:name=" Com.tencent.connect.common.AssistActivity "            android:theme=" @android: Style/theme.translucent.notitlebar "             android:screenorientation= "Portrait"/><activity        android:name= "Com.tencent.tauth.AuthActivity"        android:nohistory= "true"        android:launchmode= "Singletask" >    <intent-filter>            <action Android:name= "Android.intent.action.VIEW"/><category android:name= "Android.intent.category.DEFAULT"/> <category android:name= "Android.intent.category.BROWSABLE"/>            <data android:scheme= "Tencent your AppID"/ >     </intent-filter></activity><application>

Where you have added "Android.permission.INTERNET" and "Android.permission.ACCESS_NETWORK_STATE" permissions, you do not need to add them again.

and "Your AppID" to replace the specific application of AppID, such as your AppID is "222222", then the <data> tag should be:

<data android:scheme= "tencent222222"/>

3. Writing Android Code

String text = (string) tittle.gettext (); Qqauth Mqqauth = qqauth.createinstance ("10000000", Mcontext); 10000000 the App_id,mcontext applied for you is the context WPA MWPA = new WPA (this, Mqqauth.getqqtoken ()); String ESQ = "512821255";  512821255 QQ number for customer service int ret = mwpa.startwpaconversation (ESQ, "Hello, I am happy to see this commodity ~\n" +text); Customer service QQIF (ret! = 0) {//if RET is not 0, it means that the calling SDK has an error toast.maketext (Getapplicationcontext (), "Sorry, there was an error in contacting customer Service ~." ERR: "+ ret, Toast.length_long). Show ();}

Text in the content I get is the Product Details page of the title text, do contact customer service opening Tips



Related Article

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.