Launching external application from my app

后端 未结 5 1341
春和景丽
春和景丽 2020-12-16 06:25

I would like to launch an app the user selects from within my application. However, I\'m not sure how I\'d go about doing this. I\'ve tried this:

Intent inte         


        
5条回答
  •  有刺的猬
    2020-12-16 07:02

    I use this code for that purpose:

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClassName("com.android.settings", "com.android.settings.Settings"); 
    startActivity(intent);
    

    This will launch the Settings app, you can use these also:

    intent.setClassName("com.android.music", "com.android.music.MediaPlaybackActivityStarter");
    intent.setClassName("com.android.contacts", "com.android.contacts.DialtactsContactsEntryActivity");
    intent.setClassName("com.android.contacts", "com.android.contacts.DialtactsActivity");
    

    The first starts the default music app, the second the contacts, and the third the dialer. Hope this helps.

提交回复
热议问题