Shai L
Shai L

Reputation: 1

Changing the starting activity

Hello everybody :) I have a problem that couldn't be solved using google(!) so I turn fr your help!

I created an app with one activity, and it works just fine. Having though more about the app, I decided to add another activity which be the welcome screen of the app, with a nice logo and some buttons. This app should direct the user to the activity I mentioned before. The only trouble is - I can't find out where and how can I determine which activity should launch first, the moment the app loads. Do I need to create the entire app from scratch, but this time programing the home activity first? there must be a simpler way...

Thanks in advance, Shai :)

Upvotes: 0

Views: 382

Answers (2)

Sora
Sora

Reputation: 409

As explained by Elijah Cornell,add your 'WelcomeScreen' activity as the main activity and your existing activity as a normal activity entry in th AndroidManifest.xml

'This app should direct the user to the activity I mentioned before'--Do you mean 'app' as a seperate application or is it just another activity in the same application?

If you mean 'activity', you can start the existing activity(the one you already have) on some event of any of the widgets present(ex: 'onClick' of button widget)

Upvotes: 0

Elijah Cornell
Elijah Cornell

Reputation: 431

In your AndroidManifest.xml add the following < intent-filter > elements to the action you want to set as you initial/default:

<activity android:name=".YourMainAction" android:label="@string/app_name">
     <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
</activity>

Upvotes: 1

Related Questions