In my learning process at Android Development, I came across two different ways to start a new activity. And now I'm starting to wonder.
Both of them work great. However, I want to know whether it is better to use one of the options and why?
My first example (and the one that I like more so far):
Intent intent = new Intent(this, MainMenuActivity.class);
this.startActivity(intent);
And the second:
startActivity(new Intent("com.example.MENUSCREEN"));
Where do I need to add android: name to my intent filter in manifest:
<activity
android:name="com.example.MainMenuActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="com.example.MENUSCREEN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
And I realized that itβs right, that the intention is similar to the fact that I intend to do something? "Intention" to do an action.
source
share