简体   繁体   中英

Want to launch another activity on start up page without using any listener?

Example I have a java class that has sliding menu code which the java name is Leftandright.java.

Then I have a Main_Activity, but without any listener I want the Application to launch at the LeftandRight.java page. How do I do that?

You can set the starting activity in manifest file, AndroidManifest.xml , by declaring that Activity as a main activity.

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

Or, you can add this code in Main_Activity.java (although this is a VERY BAD approach, do not use unless you know what you're doing)

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    startActivity(new Intent(this, LeftandRight.class));
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM