How do I programmatically launch a specific application?

后端 未结 10 675
余生分开走
余生分开走 2020-11-29 03:43

I want to launch a specif application.

I know how to do Intents but I want to avoid the selection menu if there are multiple apps that can handle the intent, I want

10条回答
  •  抹茶落季
    2020-11-29 04:42

    Launch app using Intent with ComponentName

    ComponentName cName = new ComponentName("packageName","packagename.yourMainActivity");
    Intent intent = new Intent("android.intent.action.MAIN");
    intent.setComponent(cName);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(intent);
    

提交回复
热议问题