在加载 mainActivity 前 3 秒显示徽标
Showing logo 3 seconds before loading mainActivity
我想制作一个徽标(一个自己的 activity)在主 activity 加载前 3 秒在自己的 activity 中显示,当启动我的 android 应用程序时.哪种方法最简单?
我搜索过这个论坛,我只能找到一个关于这个主题的回答问题,但不幸的是它对我没有用。
我想你指的是如何实现启动画面,
创建一个新的空 activity,在本例中我将其命名为 Splash;
public class SplashScreen extends Activity {
// Sets splash screen time in miliseconds
private static int SPLASH_TIME = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// run() method will be executed when 3 seconds have passed
//Time to start MainActivity
Intent intent = new Intent(Splash.this, MainActivity.class);
startActivity(intent );
finish();
}
}, SPLASH_TIME);
}
}
确保您已在清单文件中将 Splash activity 设置为启动器 activity:
<activity
android:name=".Splash"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
我想制作一个徽标(一个自己的 activity)在主 activity 加载前 3 秒在自己的 activity 中显示,当启动我的 android 应用程序时.哪种方法最简单?
我搜索过这个论坛,我只能找到一个关于这个主题的回答问题,但不幸的是它对我没有用。
我想你指的是如何实现启动画面,
创建一个新的空 activity,在本例中我将其命名为 Splash;
public class SplashScreen extends Activity {
// Sets splash screen time in miliseconds
private static int SPLASH_TIME = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// run() method will be executed when 3 seconds have passed
//Time to start MainActivity
Intent intent = new Intent(Splash.this, MainActivity.class);
startActivity(intent );
finish();
}
}, SPLASH_TIME);
}
}
确保您已在清单文件中将 Splash activity 设置为启动器 activity:
<activity
android:name=".Splash"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>