To make the HomePage
your first activity, edit your Manifest file such that it has the intent filter for action.MAIN
. And you dont have to define anything about layouts in the Manifest file. Only the Activity declaration (which you already have)
So your new manifest file would look like
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.myphoneapp.MainActivity"
android:label="@string/title_activity_main" >
</activity>
<activity
android:name="com.myphoneapp.DisplayMessageActivity"
android:label="@string/title_activity_display_message"
android:parentActivityName="com.example.myphoneapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myphoneapp.MainActivity" />
</activity>
<activity
android:name="com.myphoneapp.HomePage"
android:label="@string/homepage"
android:parentActivityName="com.example.myphoneapp.MainActivity" >
<!-- Move the intent filter to HomePage -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myphoneapp.MainActivity" />
</activity>
</application>
</manifest>
And for the button to start mainActivity, you have already done that in HomePage.java
ScheduleBtn = (Button) findViewById(R.id.home_btn);
ScheduleBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(HomePage.this, MainActivity.class);
HomePage.this.startActivity(myIntent);
}
});
This code (taken from your HomePage.java
opens MainActivity from an intent