52 lines
2.0 KiB
Java
52 lines
2.0 KiB
Java
package com.gh.common.util;
|
||
|
||
import android.content.Context;
|
||
import android.content.Intent;
|
||
import android.net.Uri;
|
||
import android.text.TextUtils;
|
||
|
||
import com.lightgame.utils.Util_System_ClipboardManager;
|
||
import com.lightgame.utils.Utils;
|
||
|
||
/**
|
||
* Created by khy on 2017/3/30.
|
||
*/
|
||
public class QQUtils {
|
||
|
||
public static void startQQSession(Context context, String qq) {
|
||
if (TextUtils.isEmpty(qq)) {
|
||
qq = "2586716223";
|
||
}
|
||
if (ShareUtils.isQQClientAvailable(context)) {
|
||
//安装了QQ会直接调用QQ,打开手机QQ进行会话 QQ号:2586716223
|
||
String chatType;
|
||
if (qq.startsWith("400") || qq.startsWith("800")) {
|
||
chatType = "crm";
|
||
} else {
|
||
chatType = "wpa";
|
||
}
|
||
String str = "mqqwpa://im/chat?chat_type=" + chatType + "&uin=" + qq + "&version=1&src_type=web";
|
||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
|
||
} else {
|
||
//没有安装QQ 复制账号
|
||
// ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||
// cmb.setText(qq);
|
||
Util_System_ClipboardManager.setText(context, qq);
|
||
Utils.toast(context, "已复制" + qq);
|
||
}
|
||
}
|
||
|
||
public static boolean joinQQGroup(Context context, String key) {
|
||
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));
|
||
// 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||
try {
|
||
context.startActivity(intent);
|
||
return true;
|
||
} catch (Exception e) {
|
||
// 未安装手Q或安装的版本不支持
|
||
return false;
|
||
}
|
||
}
|
||
}
|