Android 发起加入QQ群、打开网址、启动拨打电话界面

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/admans/article/details/82180029
   /****************
     *
     * 发起添加群流程。     *
     * @param key 由官网生成的key
     * @return 返回true表示呼起手Q成功,返回fals表示呼起失败
     ******************/
    public static void joinQQGroup(Activity _this, 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
        {
            _this.startActivity(intent);
        } catch (Exception e)
        {
            // 未安装手Q或安装的版本不支持
            ToastUtils.show("未安装手Q或安装的版本不支持");
        }
    }
    
    /**拨打电话 (只打开拨打电话拨号界面,不打电话)
     * @param _this
     * @param phoneNum
     */
    public static void callTel(Activity _this, String phoneNum)
    {
        try
        {
            Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNum));
            _this.startActivity(intent);
        }
        catch (Exception e){
            ToastUtils.show("设备不支持拨打电话");
            Log.e("callTel", "callTel: "+e.getMessage() );
        }
    }
    
    /**通过默认浏览器 打开网址
     * @param _this
     * @param url
     */
    public static void openUrl(Activity _this, String url)
    {
        Uri uri = Uri.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        _this.startActivity(intent);
    }

QQ群管理地址:https://qun.qq.com/join.html 获取key

猜你喜欢

转载自blog.csdn.net/admans/article/details/82180029
今日推荐