zoukankan      html  css  js  c++  java
  • Android实现欢迎界面,点击进入应用

    在主线程中开启一个新线程,每隔100ms检查一下时间是否到达自己预设的显示时间,到达则进入应用

    实现屏幕的触摸事件,当触摸的时候,进入应用

    package com.example.administrator.bigelephantbike;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.MotionEvent;
    import android.view.Window;
    
    public class WelcomePageActivity extends Activity {
        protected boolean _active = true;
        protected int _splashTime = 5000;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.activity_welcome_page);
            Thread splashTread = new Thread() {
                @Override
                public void run() {
                    try {
                        int waited = 0;
                        while (_active && (waited < _splashTime)) {
                            sleep(100);
                            if (_active) {
                                waited += 100;
                                Log.d("hh", "wait");
                            }
                        }
                    } catch (InterruptedException e) {
                        // do nothing
                    } finally {
                        finish();
                        Intent intent =new Intent(WelcomePageActivity.this,MipcaActivityCapture.class);
                        intent.putExtra("name","welcome");
                        startActivity(intent);
                        Log.d("hh", "start 扫描");
                        finish();
                    }
                }
            };
            splashTread.start();
        }
    
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                _active = false;
            }
            return true;
        }
    }
  • 相关阅读:
    Linux安装nginx
    Linux安装vsftp服务
    maven的Tomcat插件使用
    Mybatis逆向工程生成代码
    千里之行,始于足下
    java 通过反射获取注解
    天气预报需要用到的jar包
    JDBC 利用反射 配置文件
    从网页下载图片的代码
    装箱/拆箱 对象排序
  • 原文地址:https://www.cnblogs.com/rainhome/p/5443450.html
Copyright © 2011-2022 走看看