android 应用调用QQ交流,类似客服

http://wiki.open.qq.com/wiki/mobile/SDK%E4%B8%8B%E8%BD%BD

创建一个工程,并把open-sdk.jar文件和mta_sdk_x.x.x.jar文件拷贝到libs(或lib)目录下,如下图所示:

选中open-sdk.jar和mta_sdk_x.x.x.ja,右键菜单中选择Build Path, 选择Add to Build Path
2.给应用的AndroidManifest增加SDK需要的配置;
在应用的AndroidManifest.xml增加配置的<application>节点下增加以下配置(注:不配置将会导致无法调用API)
<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你的AppId" />     </intent-filter></activity>
其中,如果你已经添加了"android.permission.INTERNET"和"android.permission.ACCESS_NETWORK_STATE"权限,则无需重复添加。

而"你的AppId"则要替换成具体应用的AppId,例如你的AppId是"222222",则<data>标签应该是这样的:

<data android:scheme="tencent222222" />
3.编写Android代码
String text = (String) tittle.getText();QQAuth mqqAuth = QQAuth.createInstance("10000000", mContext); // 10000000为你申请的APP_ID,mContext是上下文            WPA mWPA = new WPA(this, mqqAuth.getQQToken());            String ESQ = "512821255";  //512821255为客服QQ号            int ret = mWPA.startWPAConversation(ESQ, "你好,我正在乐宠看这个商品~\n"+text); //客服QQ            if (ret != 0) { //如果ret不为0,就说明调用SDK出现了错误                Toast.makeText(getApplicationContext(),                        "抱歉,联系客服出现了错误~. error:" + ret,                        Toast.LENGTH_LONG).show();            }
text中的内容我取得是商品详情页中的标题文字,做联系客服的开场提示

更多相关文章

  1. Android(安卓)activity概述
  2. 配置环境将win32项目移植到Android
  3. 【Fragment使用】(二)Android之取消ViewPage+Fragment的预加载
  4. Java乔晓松-android中调用系统拍照功能并显示拍照的图片
  5. Android(安卓)Studio安装及环境配置笔记
  6. android如何为listview的每项中edittext控件添加textwacher
  7. Android在代码中打开Wifi、移动网络和GPS
  8. Ubuntu 14.04.3上配置并成功编译Android(安卓)6.0 r1源码
  9. MyEclip1se8.5搭建Android环境

随机推荐

  1. Android(安卓)Touch事件传递机制
  2. Android(安卓)动画系列之自定义补间动画
  3. Android(三)数据存储之三SQLite嵌入式数据
  4. Android三种XML解析
  5. Android(安卓)之AsyncHttpClient
  6. 在Ubuntu上为Android增加硬件抽象层(HAL)模
  7. Android(安卓)之 使用MediaPlayer播放音
  8. Google Android(安卓)应用程序结构
  9. OpenGL ES for Android(安卓)环境搭建
  10. Android自动化测试工具——Monkey