Face Value
Face Value

Reputation: 49

Ordering activities in Android Manifest

Having issues trying to order the some of my activities in my application. Have implemented some ideas that I have seen on SO, but to no avail.

At the minute, my application is going SplashScreen > MainActivty. I want SplashScreen > LoginActivity > MainActivity

Any indications on where I'm going wrong would be appreciated.

Manifest

<activity
        android:name="com.example.XXX.myapplication.SplashScreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name="com.example.XXX.myapplication.LoginActivity"
        android:parentActivityName=".SplashScreen">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.XXX.myapplication.SplashScreen" />
    </activity>

    <activity
        android:name=".SignUpActivity" />

    <activity
        android:name="com.example.XXX.myapplication.MainActivity"
        android:parentActivityName=".LoginActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.XXX.myapplication.LoginActivity"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
    </activity>

Upvotes: 1

Views: 1590

Answers (4)

Manish
Manish

Reputation: 9

    You can not ordering Activities by Manifest 

    1.Your Launch page is Splash.So you can write below code in splash page

        Thread timerThread = new Thread(){
                public void run(){
                    try{
                        sleep(3000);
                    }catch(InterruptedException e){
                        e.printStackTrace();
                    }finally{
                        startActivity(new Intent(SplashScreenActivity.this,YourActivity.class));
                        finish();
                    }
                }
            };
            timerThread.start();

You can write your Login Activity on plcae of YourActivity.

2.On Click Login button Ho to main Activity

Upvotes: 0

Olaoye Oluwapelumi
Olaoye Oluwapelumi

Reputation: 484

Place and `Intent-filter` tag in your intended entry activity in AndroidManifest.xml file like this

```
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
```

If your initial activity is a place, start the next activity in your runnable thread as shown below.

```
    new Handler().postDelayed(new Runnable(){
        @Override
        public void run() {
        /* Create an Intent that will start the Menu-Activity. */
        Intent(SplashActivity.this,ACTIVITY_TO_GO_TO.class);
        startActivity(mainIntent);
        finish();
        }
    }, TIME_OUT_NOW);
```

You can then move to anywhere else in ACTIVITY_TO_GO_TO activity.

Upvotes: 0

Ясир
Ясир

Reputation: 155

You should do it programmatically in Java, in your SplashScreen Class, you should have something like :

startActivity(new Intent(SplashScreen.this, LoginActivity.class));

Example :

private final int SPLASH_DISPLAY_TIME = 5000;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_screen);

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            Intent myIntent = new Intent(SplashScreen.this, LoginActivity.class);
            startActivity(myIntent);
            finish();
        }
    },SPLASH_DISPLAY_TIME);
}

Upvotes: 1

Ebay89
Ebay89

Reputation: 690

You don't order activities in the manifest like this. Set your splash screen to the default activity. In the Java code for splash activity start mainactivity with the startactivity method. Then in loginactivity call startactivity for mainactivity.

https://developer.android.com/training/basics/firstapp/starting-activity.html

Upvotes: 4

Related Questions