Android程序调用QQ的接口方法

来源:互联网 发布:阿里云服务器类型 编辑:程序博客网 时间:2024/06/05 17:14
  1. 方式一:引用
    • 进入QQ聊天
String url = "mqqwpa://im/chat?chat_type=wpa&uin=" + qq; startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
 -   个人介绍界面
String  url = "mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + qq                    + "&card_type=person&source=qrcode";  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
 -   QQ公众号
String url="mqq://im/chat?chat_type=crm&uin="+qq;   startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
 -   QQ群介绍界面 
String  url = "mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + qqnum                    + "&card_type=group&source=qrcode";  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
  1. 方式二:调用方法

    • 封装一个方法
public static void openQQ(Context mContext, int type, String qq) {        String url = null;        switch (type) {        case 1:            //  进入QQ聊天             url = "mqqwpa://im/chat?chat_type=wpa&uin=" + qq;            break;        case 2:            //  个人介绍界面             url = "mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + qq                    + "&card_type=person&source=qrcode";            break;        case 3:            // QQ群介绍界面             url = "mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + qqnum                    + "&card_type=group&source=qrcode";            break;        case 4:            // QQ公众号              url="mqq://im/chat?chat_type=crm&uin="+qq;              break;        default:            break;        }        mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));    }
原创粉丝点击