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;
        }
    }
  • 相关阅读:
    Android布局1
    QML 自定义折线图
    QML ChartView 画折线图
    操作系统复习笔记
    Redis的使用
    Git的基本使用
    Python json to excel/csv
    .NET中进行Base64加密解密
    用 IIS 7、ARR 與 Velocity 建设高性能的大型网站
    微信突然出现redirect_uri 参数错误
  • 原文地址:https://www.cnblogs.com/rainhome/p/5443450.html
Copyright © 2011-2022 走看看