Intent intent =newIntent(Intent.ACTION_MAIN);//设置action
intent.addCategory(Intent.CATEGORY_LAUNCHER);//设置category
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//设置singleTask启动模式
ComponentName componentName =new ComponentName("com.lazyxu.startmode","com.lazyxu.startmode.MainActivity");
//封装了包名+类名
intent.putExtra("package","页面跳转");//设置数据
intent.setComponent(componentName);
startActivity(intent);
-
方法二:
通过包名(打开启动页,不能打开特定的页面)
PackageManager packageManager =DemoActivity.this.getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage("com.lazyxu.startmode");
startActivity(intent);
Intent intent =new Intent();
intent.setAction("com.action.test");
startActivity(intent);