[英]Arrange activities in android studio
I have a splash screen in my project it opens first with intent filter.我的项目中有一个启动画面,它首先使用 Intent 过滤器打开。 After that it opens the main activity.
之后它打开主要活动。 But i created new activity that should be opened next to splash screen how to do that?
但是我创建了应该在启动画面旁边打开的新活动,该怎么做?
I have created three activities for example splash screen, main activity, login screen, Splash screen first opens next to that i need to open the login screen next only main activity.我已经创建了三个活动,例如启动画面、主活动、登录屏幕,启动画面首先在旁边打开,我需要在主活动旁边打开登录屏幕。
xml code xml代码
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_main"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_main_round"
android:supportsRtl="true"
android:theme="@style/Theme.WeatherApp">
<activity
android:name=".SplashScreen"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".HomeActivity"
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden"
tools:ignore="LockedOrientationActivity" />
</application>
new Handler().postDelayed(
new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashScreen.this, Login.class);
finish();
}
},
4000);
There are few ways to achieve this.实现这一目标的方法很少。 This is one of my way.
这是我的一种方式。
First, at your AndroidManifest.xml
, make sure you make your SplashActivity
becomes your launcher
.首先,在您的
AndroidManifest.xml
中,确保您使SplashActivity
成为您的launcher
。 Then, at the onCreate
method for your SplashActivity
, do some delay, checking some stuff, is this user login or not.然后,在
SplashActivity
的onCreate
方法中,做一些延迟,检查一些东西,这个用户是否登录。 Last, go to next activity.最后,go 到下一个活动。
<activity
android:name="company.com.ui.SplashActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.