羊皮书APP(Android版)开发系列(四)全屏幕延迟启动

APP启动时经常会有一张启动图片,有几秒钟的展示时间,做法很简单,使用Handler的postDelayed方法即可。

  • 配置全屏:在styles.xml中定义Theme,代码如下:
<!--设置-全屏-->
<style name="NoTitleFullscreen" parent="Theme.AppCompat.Light.NoActionBar"><item name="android:windowNoTitle">true</item><item name="windowActionBar">false</item><item name="android:windowFullscreen">true</item&gt<item name="android:windowContentOverlay">@null</item>
</style>
  • 在AndroidManifest.xml文件中使用这个Theme
android:theme="@style/NoTitleFullscreen"
  • 配置启动延迟代码如下:
private void delayedStart(){new Handler().postDelayed(new Runnable() {@Overridepublic void run() {startActivity(IntentUtil.getLauncherIntent().setClass(getApplicationContext(), MainActivity.class));finish();}}, 3000);} 
  • 调用方式:在Activity的onCreate方法中调用即可:
delayedStart();
  • 这里有一个Intent的工具类IntentUtil.java,作用是用于启动Activity并可以传递参数。IntentUtil.java代码如下:
package cn.studyou.parchment.utils;import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;/*** 基本功能:Intent工具类* 创建:王杰* 创建时间:16/3/7* 邮箱:w489657152@gmail.com*/
public class IntentUtil {private static final String TAG = IntentUtil.class.getSimpleName();public static Intent getLauncherIntent() {Intent intent = new Intent(Intent.ACTION_MAIN);intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);intent.addCategory(Intent.CATEGORY_HOME);return intent;}public static void logIntent(String tag, Intent intent) {if (intent == null) {return;}StringBuffer sb = new StringBuffer();sb.append("\nAction:" + intent.getAction());sb.append("\nData:" + intent.getData());sb.append("\nDataStr:" + intent.getDataString());sb.append("\nScheme:" + intent.getScheme());sb.append("\nType:" + intent.getType());Bundle extras = intent.getExtras();if (extras != null && !extras.isEmpty()) {for (String key : extras.keySet()) {Object value = extras.get(key);sb.append("\nEXTRA: {" + key + "::" + value + "}");}} else {sb.append("\nNO EXTRAS");}Log.i(tag, sb.toString());}public static int sdkVersion() {return new Integer(Build.VERSION.SDK).intValue();}public static void startDialer(Context context, String phoneNumber) {try {Intent dial = new Intent();dial.setAction(Intent.ACTION_DIAL);dial.setData(Uri.parse("tel:" + phoneNumber));context.startActivity(dial);} catch (Exception ex) {Log.e(TAG, "Error starting phone dialer intent.", ex);Toast.makeText(context,"Sorry, we couldn't find any app to place a phone call!",Toast.LENGTH_SHORT).show();}}public static void startSmsIntent(Context context, String phoneNumber) {try {Uri uri = Uri.parse("sms:" + phoneNumber);Intent intent = new Intent(Intent.ACTION_VIEW, uri);intent.putExtra("address", phoneNumber);intent.setType("vnd.android-dir/mms-sms");context.startActivity(intent);} catch (Exception ex) {Log.e(TAG, "Error starting sms intent.", ex);Toast.makeText(context,"Sorry, we couldn't find any app to send an SMS!",Toast.LENGTH_SHORT).show();}}public static void startEmailIntent(Context context, String emailAddress) {try {Intent intent = new Intent(Intent.ACTION_SEND);intent.setType("plain/text");intent.putExtra(Intent.EXTRA_EMAIL,new String[]{emailAddress});context.startActivity(intent);} catch (Exception ex) {Log.e(TAG, "Error starting email intent.", ex);Toast.makeText(context,"Sorry, we couldn't find any app for sending emails!",Toast.LENGTH_SHORT).show();}}public static void startWebIntent(Context context, String url) {try {Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));context.startActivity(intent);} catch (Exception ex) {Log.e(TAG, "Error starting url intent.", ex);Toast.makeText(context,"Sorry, we couldn't find any app for viewing this url!",Toast.LENGTH_SHORT).show();}}
}
  • 使用方式:
startActivity(IntentUtil.getLauncherIntent().setClass(getApplicationContext(), MainActivity.class).putExtra("name","name"));

  • 原文地址:http://blog.csdn.net/wjwj1203/article/details/50853053
  • 我的github地址:https://github.com/wjie2014
  • 我的博客地址:http://blog.studyou.cn/
  • 我的CSDN博客地址:http://blog.csdn.net/wjwj1203
  • 我的Gmail邮箱:w489657152@gmail.com

羊皮书APP(Android版)开发系列(四)全屏幕延迟启动相关推荐

  1. 【转】Android 驱动开发系列四

    原文网址:http://www.2cto.com/kf/201304/202040.html 时隔多日,终于都抽出时间来写blog了.废话不多说,接着上一篇,这里将介绍如何编写HAL层(硬件抽象层)对 ...

  2. Android 系统开发系列四

    这里将介绍如何编写HAL层(硬件抽象层)对应的JNI方法. 1.定义JNI层接口 进入到android-4.0.4_r1.2/hardware/libhardware/include/hardware ...

  3. Android商城开发系列

    Android商城开发系列(一)--开篇 Android商城开发系列(二)--App启动欢迎页面制作 Android商城开发系列(三)--使用Fragment+RadioButton实现商城底部导航栏 ...

  4. android 相机编程,Android相机开发系列

    Android Camera Develop Series 简介 Android相机开发系列文章循序渐进,教你从一个没有任何功能的相机APP开始,逐步完善实现一般相机APP的各种功能,甚至还能拿来做图 ...

  5. Android Camera开发系列(下)——自定义Camera实现拍照查看图片等功能

    Android Camera开发系列(下)--自定义Camera实现拍照查看图片等功能 Android Camera开发系列(上)--Camera的基本调用与实现拍照功能以及获取拍照图片加载大图片 上 ...

  6. Android 快速开发系列 打造万能的ListView GridView 适配器

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/38902805 ,本文出自[张鸿洋的博客] 1.概述 相信做Android开发的写 ...

  7. Android蓝牙开发系列文章-扫不到蓝牙设备,你的姿势对了吗?

    在写<Android蓝牙开发系列文章-蓝牙音箱连接>时,计划细化出两篇文章,分别是: 关于蓝牙设备类型分类的,这个已经完成了,阅读请点击<Android蓝牙开发系列文章-蓝牙设备类型 ...

  8. Android蓝牙开发系列文章-玩转BLE开发(一)

    我们在<Android蓝牙开发系列文章-策划篇>中计划讲解一下蓝牙BLE,现在开始第一篇:Android蓝牙开发系列文章-玩转BLE开发(一).计划要写的BLE文章至少分四篇,其他三篇分别 ...

  9. Android Studio开发(四)SQLite数据库的DAO标准CRUD操作模拟微信通讯录

    Android Studio开发(四)SQLite数据库的DAO标准CRUD操作模拟微信通讯录 Android Studio开发(四)SQLite数据库的DAO标准CRUD操作模拟微信通讯录 一.任务 ...

最新文章

  1. Netscape Mozilla源代码指南
  2. iOS学习笔记---oc语言第八天
  3. 详解centos7使用无线wifi连接的方法
  4. python子进程关闭fd_如果创建了multiprocessing.Pool,Python子进程wait()将失败
  5. Delete Edges
  6. (52)多路时钟复用FPGA如何约束一(片外时钟复用约束)
  7. Broken Keyboard(悲剧文本)
  8. linux pagecache与内存占用
  9. 高德地图记录跑步轨迹_朋友圈晒跑步 亲测高德地图和百度地图哪个更实用
  10. 安装Rhythmbox mp3插件
  11. git - 1.基础
  12. 如何做好性能压测(一) | 压测环境的设计和搭建
  13. java tapestry_java Tapestry4.1.2入门说明教程
  14. spring boot高校二手教材管理平台 毕业设计-附源码231057
  15. 神策2020数据驱动用户大会:新愿景 + 新定位 + 新舰队正式亮相!
  16. 开发 iOS 的 VOIP 客户端
  17. keras冻结_Keras 实现加载预训练模型并冻结网络的层
  18. 彩铃多多 v2.4.5.0
  19. vue 视频播放插件vue-video-player的使用
  20. Python Flask 构建微电影视频网站

热门文章

  1. 【嵌入式操作系统】实验2:GPIO编程及应用
  2. uniapp 处理过去时间对比现在时间的时间差 如刚刚、几分钟前,几小时前,几个月前
  3. Docker下Nacos配置应用开发
  4. 奇怪的知识又增加了9——OTGUSB网络
  5. 沉睡者:你会的套路我都会,只是我不对你用而已。
  6. 【C++札记】标准模板库string
  7. estore订单提交功能
  8. bootstrapr表格父子框_bootstrap-table的基本使用方法和属性
  9. 使用Duplicate Cleaner删除重复文件软件教程
  10. 传奇无双为什么显示服务器异常,传奇无双闪退黑屏怎么办?传奇无双闪退黑屏解决方法分享...