安卓界面QQ 一键加群,微信号手机号跳转实现
1、Android中根据QQ号码或者QQ群号码,跳转到指定的QQ号码聊天或者QQ群方法
跳转到指定的QQ群方法:
2、跳转到指定的QQ号码方法:
3、Android中根据微信号,跳转到微信程序(含有剪贴板功能)
privatevoidOpenWeiXin(String weixin){
try{
// 获取剪贴板管理服务
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
//将文本数据(微信号)复制到剪贴板
cm.setText(weixin);
//跳转微信
Intent intent = newIntent(Intent.ACTION_MAIN);
ComponentName cmp = newComponentName("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();
}
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);
returntrue;
} catch (Exception e) {
//未安装手Q或安装的版本不支持
returnfalse;
}
5、安卓中手机号的拨打
tv_phone= ((TextView) findViewById(R.id.tv_phone));
tv_phone.setOnClickListener(newView.OnClickListener() {
@Override
publicvoidonClick(View view){
Intent intent = newIntent(Intent.ACTION_CALL, Uri.parse("tel:"+ tv_phone.getText()));
if(ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(intent);
}
});