How to run a certain activity in Android Studio?

后端 未结 6 1150
渐次进展
渐次进展 2021-02-04 01:31

For instance, I have a few activities within one app, and in order to see a certain activity\'s UI or whatever, I need to run a certain activity that is not the launcher of the

6条回答
  •  天涯浪人
    2021-02-04 01:53

    Very easy. Start by exporting the activity you need to run:

    Add android:exported="true" in the Activity declaration in the Manifest. This is because am is an external application, and you need to export Activities to allow external application to start them.

    Go to "Edit Configurations..." in the "Run" menu.

    In the left pane, select your application. In the right pane, in the "General" tab, in the "Launch Options" section, there is a "Launch:" dropdown.

    Select "Specified Activity", and enter the name of your activity as it appears in your Manifest.

    You can create as many Configurations as you like, and name them according however you like, for example to indicate which activity is being started.

提交回复
热议问题