Skip to content Skip to sidebar Skip to footer

How To Run Specific Activity In Android Emulator?

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??? when i p

Solution 1:

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

Solution 2:

Go to the AndroidManifest.xml and cut

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

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

Solution 3:

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);

    }

Solution 4:

publicvoidonClick(View v){

    Intent i;

    i = newIntent(this, YourActivity1.class);
    startActivity(i);

    i = newIntent(this, YourActivity2.class);
    startActivity(i);

    i = newIntent(this, YourActivity3.class);
    startActivity(i);

    i = newIntent(this, YourActivity4.class);
    startActivity(i);
}

Solution 5:

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

Post a Comment for "How To Run Specific Activity In Android Emulator?"