Unity Android 跳转拨号界面和一键加群

请添加图片描述

拨号

AndroidStudio中

public void CallPhone(String phone)
{
    Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+phone));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}

AndroidManifest添加拨号权限
<uses-permission android:name=“android.permission.CALL_PHONE” />

Unity Android 一键加群

首先在腾讯开放者平台注册开发者账号
https://open.tencent.com/
审核完成,在https://qun.qq.com/join.html中拿到具体的key
在这里插入图片描述

AndroidStudio中调用方法传入官网的key

public void JoinQQGroup(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 {
        startActivity(intent);
    } catch (Exception e) {
        // 未安装手Q或安装的版本不支持
Toast.makeText(this,"未安装手Q或安装的版本不支持",Toast.LENGTH_LONG);
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_44806700/article/details/123223471
今日推荐