• 自动秒收录
  • 软件:1974
  • 资讯:4527|
  • 收录网站:301505|

IT精英团

android常用action方法

android常用action方法

作者/景文

android常用action方法

作者/景文

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是发送过去的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, "群入口已经关闭", 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("//")) {                 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可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面    //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)         try {             activity.startActivity(intent);             return true;         } catch (Exception e) {             // 未安装手Q或安装的版本不支持             return false;         }     }
点击这里复制本文地址 以上内容由IT精英团整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
退出阅读|首页