android跳转QQ陌生人聊天或者加入QQ群

首先是跳转陌生人聊天:

只需要陌生人的qq号就好了

try {
    String url = "mqqwpa://im/chat?chat_type=wpa&uin=" +QQ号;
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
} catch (Exception e) {
    showShortToast("请先安装QQ!");
}

接着是申请加群:

需要qq群的key,获取地址是  http://qun.qq.com/join.html

        Intent intent = new Intent();
        intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D"  + KEY));
        try {
            startActivity(intent);
        } catch (Exception e) {
            showShortToast(" 未安装手Q或安装的版本不支持");
        }

你可能感兴趣的:(android,技巧)