Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change start Activity dynamically?

I am working on an android app. I want to change Start activity dynamically. i mean when user start app first time then start activity will different and when start second time start activity change.This will skip first two activity and move to third activity .how can i achieve this.

like image 392
user2223286 Avatar asked Mar 29 '13 05:03

user2223286


People also ask

Can an activity start itself Android?

Yes it is. If your requirement are like that then there is no harm in doing that.

Which method is use for start activity?

The startActivity() method starts an instance of the DisplayMessageActivity that's specified by the Intent . Next, you need to create that class.


1 Answers

You cannot change the first activity dynamically, but you can create a transparent activity like this:

<activity
    android:name=".ActivityLauncher"
    android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

and select next activity in the onCreate method:

if ( logged() ) {
    intent = new Intent(this,MainActivity.class);
} else {
    intent = new Intent(this,SignInActivity.class);
}
startActivity(intent);
finish();
like image 63
Mikalai Daronin Avatar answered Sep 19 '22 12:09

Mikalai Daronin