android launcher启动应用

private void startPttApp(Context context,String pkgName){
    Log.i(TAG,"startPttApp >> begin");
    Intent intent = context.getPackageManager().getLaunchIntentForPackage(pkgName);
    String className = intent.getComponent().getClassName();
    ComponentName componet = new ComponentName(pkgName, className);
    Intent i  = new Intent(Intent.ACTION_MAIN)
            .addCategory(Intent.CATEGORY_LAUNCHER)
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    i.setComponent(componet);
    context.startActivity(i);
    Log.i(TAG,"startPttApp >> end");
}
发布了376 篇原创文章 · 获赞 40 · 访问量 46万+

猜你喜欢

转载自blog.csdn.net/wangjicong_215/article/details/104551075