Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.tencent.mobieqq");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP) ;
this.startActivity(intent);
String url = "mqqwpa://im/chat?chat_type=wpa&uin=694886526";//uin是發(fā)送過去的qq號碼
Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent);
public static int lanuchWeinXin(Context context) {
try {
Intent intent = new Intent();
ComponentName cmp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI");
// intent.setAction(Intent.ACTION_VIEW);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Intent.FLAG_ACTIVITY_NEW_TASK ok 否則返回不了
intent.setComponent(cmp);
context.startActivity(intent);
return 0;
} catch (ActivityNotFoundException e) {
e.printStackTrace();
return -1;
} catch (Exception e) {
return -2;
}
}
Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.tencent.mobileqq");
if (intent == null) {
intent = new Intent();
intent.setComponent(new ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.SplashActivity"));
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP);
this.startActivity(intent);
public static boolean joinQQGroup(Activity activity, String key) {
Intent intent = new Intent();
if (SuperAppContext.getGroup() == null) {
Toast.makeText(activity, "群入口已經(jīng)關(guān)閉", Toast.LENGTH_SHORT).show();
return false;
} else {
if (SuperAppContext.getGroup().equals("default")) {
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));
} else if (SuperAppContext.getGroup().startsWith("http")) {
intent.setData(Uri.parse(SuperAppContext.getGroup()));
} else if (SuperAppContext.getGroup().contains("http://")) {
intent.setData(Uri.parse(SuperAppContext.getGroup()));
} else if (SuperAppContext.getGroup().contains("biz")) {
intent.setData(Uri.parse(SuperAppContext.getGroup()));
} else {
Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + SuperAppContext.getGroup());
}
}
// 此Flag可根據(jù)具體產(chǎn)品需要自定義铡恕,如設(shè)置,則在加群界面按返回谢揪,返回手Q主界面硫兰,不設(shè)置喧务,按返回會返回到呼起產(chǎn)品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
try {
activity.startActivity(intent);
return true;
} catch (Exception e) {
// 未安裝手Q或安裝的版本不支持
return false;
}
}