自动启动在Android的新活动 [英] Automatic start of a new activity in android

查看:145
本文介绍了自动启动在Android的新活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个Android应用程序。我有一个徽标屏幕(活动)然后我主屏幕(另一活动)。我想,当我开始我的应用我的标志画面应该再后自动2秒我的主屏幕应该会出现。任何人都可以请建议我该怎么办?

I am creating an android application. I have a logo screen(Activity) and then my home screen(another activity). I want that when I start my application my logo screen should come and then automatically after 2 sec my home screen should appear. Can anyone please suggest to me what I should do?

推荐答案

请使用。

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class Logo extends Activity {
protected boolean _active = true;
protected int _splashTime = 2000;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.logo);

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            finish();
            Intent i3 = new Intent(Logo.this, Home.class);
                startActivity(i3);
        }
    }, _splashTime);
}
}

这篇关于自动启动在Android的新活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆