Intents can among many things be used to start op a new user interface in your Android App. If you are using a MVC technique, you would like the view part to the separated into classes for itself. To do this, there is three basic steps to make:
- Create a new class for the activity
- Add the class to the Android Manifest
- Start the activity
Create a class for the user interface
Lets call this file UI:
import android.app.Activity;
public class UI extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// type your magic code here
}
}
That it basically it. A class extending the Activity – the onCreate is called when the activity is started.
NB: the super.onCreate is very important – without it the code will fail to run!
Editing the AndroidManifest.xml
The register the intent in the application, we have to edit the AndroidManifest.xml file like this:
...
<application...>
...
<activity android:name=".UI" android:label="@string/app_name">
</activity>
...
</application>
This enables us to access the UI intent created earlier.
Starting the activity
All we have to do now, is to start the new intent. This can be done with the startActivity()-function like this:
... startActivity(new Intent(this, UI.class)); ...
I hope this small guide is helpful to you. If you would like an example with more details, please let me know

september 20th, 2010 at 00:21
How do you get an Activity from an Intent? This seems untintuitve as a newbie to Android development. I launch and Intent with an Activity as follow:
Intent mapIntent = new Intent();
mapIntent.setClass(this, MathleteMapActivity.class);
// How do I get a reference to the MathleteMapActivity ‘Activity’ from the Intent ‘mapIntent’?
Chris