安卓界面上一些简单QQ 一键加群,微信号 手机号跳转,可用在app关于我们的界面中

来源:互联网 发布:java开发restful接口 编辑:程序博客网 时间:2024/05/01 09:30

1.Android中根据QQ号码或者QQ群号码,跳转到指定的QQ号码聊天或者QQ群方法

跳转到指定的QQ群方法:

String url11 = "mqqwpa://im/chat?chat_type=group&uin=456108965&version=1";startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url11)));

跳转到指定的QQ号码方法:

String url11 = "mqqwpa://im/chat?chat_type=wpa&uin=456108965&version=1";startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url11)));

2.Android中根据微信号,跳转到微信程序(含有剪贴板功能)。

private void OpenWeiXin(String weixin) {    try {        // 获取剪贴板管理服务        ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);        //将文本数据(微信号)复制到剪贴板        cm.setText(weixin);        //跳转微信        Intent intent = new Intent(Intent.ACTION_MAIN);        ComponentName cmp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI");        intent.addCategory(Intent.CATEGORY_LAUNCHER);        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);        intent.setComponent(cmp);        startActivity(intent);        Toast.makeText(this, "微信号已复制到粘贴板,请使用", Toast.LENGTH_LONG).show();    } catch (ActivityNotFoundException e) {        e.printStackTrace();        Toast.makeText(this, "您还没有安装微信,请安装后使用",Toast.LENGTH_LONG).show();    }}

3.安卓中手机号的拨打。

    tv_phone= ((TextView) findViewById(R.id.tv_phone));    tv_phone.setOnClickListener(new View.OnClickListener() {        @Override        public void onClick(View view) {            Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + tv_phone.getText()));            if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {                return;            }            startActivity(intent);        }    });

不过拨打电话是需要在配置文件添加使用权限的,不然会报错的。权限如下:

<uses-permission android:name="android.permission.CALL_PHONE" />

4.安卓一键加QQ群

    joinQQGroup("5JX8sh6BmnEqPtilnCs_f6Y3B5J1a6pR");方法参数为群号的key,可以从 http://qun.qq.com/join.html网站获取    public boolean 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);        return true;    } catch (Exception e) {        // 未安装手Q或安装的版本不支持        return false;    }}




1 0
原创粉丝点击