how to run Specific activity in android emulator?

后端 未结 6 1556
無奈伤痛
無奈伤痛 2021-01-29 00:36

i have created 4 activities in eclipse now i want to run activity 1, 2,3 ,4 repectively one by one in emulator for testing.

can any one guide me how can i run those all?

相关标签:
6条回答
  • 2021-01-29 00:55

    Go to the AndroidManifest.xml and cut

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
    

    from the Main Activity. Then paste it into the Activity that you want to start.

    0 讨论(0)
  • 2021-01-29 01:05

    You could try startActivityForResult but you may need to possibly modify your program your applications to handle this. I would suggest using one of the android sdk tools called am (activity manager). In the adb shell:

    # am start -n package-name/activity-1-name
    # am start -n package-name/activity-2-name
    # am start -n package-name/activity-3-name
    # am start -n package-name/activity-4-name
    
    0 讨论(0)
  • 2021-01-29 01:12

    Android SDK includes the JUnit framework for writing unit tests. You can use the package android.test packages to run activities under JUnit. It may be overkill for what you want but eventually you may need this functionality.

    References:

    http://junit.sourceforge.net/

    http://mylifewithandroid.blogspot.com/2008/11/junit-in-android.html

    0 讨论(0)
  • 2021-01-29 01:12

    Go to the Android Manifest file under your workspace root and double click on it to open. Go to the AndroidManifest.xml tab and change the name of the first activity to whatever activity you want to launch at run. Also make sure you rename that first activity to the other activity so ADT doesn't throw errors. Basicall, switch their names in the xml file. I had to do it because I wanted to test each activity individually before linking them. Let me know if you have any other question.

    0 讨论(0)
  • 2021-01-29 01:13

    To Run A specific Activity First Change the Activity Name In the setContentView within the Main Activity.java

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
             setContentView(R.layout.Your_Activity_Name);
    
        }
    
    0 讨论(0)
  • 2021-01-29 01:19
    public void onClick(View v) {
    
        Intent i;
    
        i = new Intent(this, YourActivity1.class);
        startActivity(i);
    
        i = new Intent(this, YourActivity2.class);
        startActivity(i);
    
        i = new Intent(this, YourActivity3.class);
        startActivity(i);
    
        i = new Intent(this, YourActivity4.class);
        startActivity(i);
    }
    
    0 讨论(0)
提交回复
热议问题