String qq = "";//填入要联系的qq
if (checkApk(getActivity(), "com.tencent.mobileqq")) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("mqqwpa://im/chat?chat_type=wpa&uin=" + qq + "&version=1")));
} else {
Toast.makeText(getActivity(), "本机未安装QQ应用", Toast.LENGTH_SHORT).show();
}
checkApk方法
/**
* 检查apk是否安装
* @param context
* @param packageName
* @return
*/
public boolean checkApk(Context context, String packageName) {
if (packageName == null || "".equals(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager().getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
如果想进行临时会话
qq登录
https://shang.qq.com/v3/index.html
1.在弹出菜单中点击’立即免费开通’
2.点击推广工具
3.点击设置
选择两项则可进行临时会话了