android app主程序启动前加载图片
android app加载启动图片需要新创建一个activity,在主activity先加载图片activity,展示过程结束后,显示主activity。具体流程如下:
一、创建图片activity的运行类
package com.smallart.myapplication; import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.WindowManager;
import android.widget.Toast;
import android.widget.ImageView;
import com.nostra13.universalimageloader.core.ImageLoader;
import java.lang.reflect.Method; public class HomeActivity extends AppCompatActivity { private ImageView mImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
hideBottomUIMenu(this);
setContentView(R.layout.activity_home); }
}
二、在AndroidManisest.xml文件中,添加activity的注册
<application
android:name="com.smallart.myapplication.Application"
android:configChanges="orientation|keyboardHidden"
android:allowBackup="true"
android:icon="@mipmap/ic_app_icon"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_app_icon_round"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity"
android:screenOrientation="sensorLandscape"
android:configChanges="orientation|keyboardHidden|screenSize">
</activity>
<activity android:name=".HomeActivity"
android:screenOrientation="sensorLandscape"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
三、显示图片,在HomeActivity.java中的onCreate中添加图片显示代码:
this.mImageView = ((ImageView)findViewById(R.id.img));
ImageLoader.getInstance().displayImage("drawable://bg_app_start.jpg", this.mImageView);
四、增加线程,5秒后切换activity,完整代码如下:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
hideBottomUIMenu(this);
setContentView(R.layout.activity_home); this.mImageView = ((ImageView)findViewById(R.id.img));
ImageLoader.getInstance().displayImage("drawable://bg_app_start.jpg", this.mImageView);
handler.sendEmptyMessageDelayed(,); } private Handler handler = new Handler() {
//Intent intent = new Intent(MainActivity.this, HomeActivity.class);
@Override
public void handleMessage(Message msg) {
getHome();
super.handleMessage(msg);
}
}; public void getHome(){
Intent intent = new Intent(HomeActivity.this, MainActivity.class);
startActivity(intent);
overridePendingTransition(, );
finish();
}
android app主程序启动前加载图片的更多相关文章
- Android之使用Android-AQuery异步加载图片(一)
第一节:转载地址(http://www.cnblogs.com/lee0oo0/archive/2012/10/25/2738299.html) // 必须实现AQuery这个类 AQuery aq ...
- android优化从网络中加载图片速度。。
从网络中加载图片主要要注意两个方面的问题: 1.内存管理:图片占的内存很大,假如图片数量多,很容易让系统抛出out of memory的异常. 同时我们也要注意不同android版本中内存管理的区别. ...
- Android之com.nostra13.universalimageloader加载图片抛出OutOfMemroyError错误的多种解决办法
com.nostra13.universalimageloader是用来加载图片非常好的框架,但是也有问题,一旦图片过多的话,很容易就会提示OutOfMemroyError错误,也就是内存溢出的问题, ...
- android列表停止滚动,加载图片,较为通用的一种办法
在Adapter的itemView里面,判断列表是否在滚动中,其实是比较麻烦的,可能耦合性会比较严重. 所以考虑了下,是否能在itemView里面,检测列表的滚动状态,并监听停止状态加载图片,实现it ...
- android 解决启动页面加载图片空白以及去掉标题栏
有时候启动页面根据白天晚上来启动时实现加载不同的图片效果,但是加载时会出现短暂的空白,解决方法如下: android:theme="@android:style/Theme.Transluc ...
- stark组件前戏之项目启动前加载指定文件
1. django项目启动时, 自定制执行某个py文件 dajngo 启动时.会将所有 路由加载到内存中. 我的目的就是在 路由加载之前,执行某个py文件. 每个app中都有一个 apps.py fr ...
- stark组件前戏(1)之项目启动前加载指定文件
django项目启动时,可以自定义执行某个py文件,这需要在任意app的apps.py中的Config类定义ready方法,并调用. from django.apps import AppConf ...
- Android之ListView和GridVIew加载图片
清除缓存:ImageLoader 对象 . clearCache(); 使用: ImageLoader loader = new ImageLoader(ApplicationContext cont ...
- Android三种基本的加载网络图片方式(转)
Android三种基本的加载网络图片方式,包括普通加载网络方式.用ImageLoader加载图片.用Volley加载图片. 1. [代码]普通加载网络方式 ? 1 2 3 4 5 6 7 8 9 10 ...
随机推荐
- C# 代码小技巧
一 .自动属性. 1.vs下输入prop,Tab键就出现了. 2.有了自动属性,我们不用再额外为一个类的每个公共属性定义一个私有字段(实际上没多大用处的字段), 但是通过反射还是可以看到对应的私有 ...
- vld for memory leak detector (release version)
有没有这样的情况,无法静态的通过启动和退出来查找内存泄露,比如网络游戏,你总不能直接关游戏那玩家怎么办? 现在vld支持release,我们可以动态的找. 1.在release版本使用vld了.< ...
- 代码管理工具libgit2sharp与sharpsvn
在使用libgit2sharp 开发时出现: LibGit2Sharp.LibGit2SharpException: too many redirects or authentication repl ...
- 如何判断win10 和office的版本
1:区分win10的版本 2:查询office 的版本
- ef join查询
temp = temp.OrderByDescending(s => s.CreateTime).Skip((param.PageIndex - ) * param.PageSize).Take ...
- Java笔记Spring(四)
spring web项目启动入口 1.首先看一下传统Java Web的配置文件web.xml,网上找的一个,参考地址:https://blog.csdn.net/github_36301064/art ...
- 通过eclipse打开jdk native源码
1.下载 eclipse http://www.eclipse.org/downloads/eclipse-packages/ 建议下载 Eclipse IDE for Eclipse Committ ...
- Go的CSP并发模型实现:M, P, G
最近抽空研究.整理了一下Golang调度机制,学习了其他大牛的文章.把自己的理解写下来.如有错误,请指正!!! golang的goroutine机制有点像线程池: 一.go 内部有三个对 ...
- oninput、onchange与onpropertychange事件的区别, 与input输入框实时检测
这几天项目着急,同时也学到好多以前没有接触过的知识.oninput.onchange与onpropertychange事件的区别, 与input输入框实时检测 onchange事件只在键盘或者鼠标操作 ...
- C#设计模式(1)——单例模式(Singleton)
单例模式即所谓的一个类只能有一个实例, 也就是类只能在内部实例一次,然后提供这一实例,外部无法对此类实例化. 单例模式的特点: 1.只能有一个实例: 2.只能自己创建自己的唯一实例: 3.必须给所有其 ...