Start MAIN activity of the current application without knowing it's name

Viewed 3686

I am trying to write an utility method, that would be able to start activity (belonging to current application) marked as "android.intent.action.MAIN". The utility method should not accept any parameters.

Desired code:

public void startMainActivity(Context context) {
    ...
}

Manifest:

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

Any ideas?

3 Answers
Related