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;
        }
    }
  • 相关阅读:
    业务需求、用户需求和功能需求
    乐观锁的两种实现方式
    数据字典
    freemarker(ftl)标签用法
    commons-lang常用方法
    前端与后端分离
    jar包导入本地maven库的操作
    本地打jar包到本地的Maven出库
    MyEclipse中好用的快捷键汇总整理
    简单的反编译class文件并重新编译的方法
  • 原文地址:https://www.cnblogs.com/rainhome/p/5443450.html
Copyright © 2011-2022 走看看