Android的启动画面 - 图像从SD卡? [英] Android splash screen - Image from SD card?

查看:233
本文介绍了Android的启动画面 - 图像从SD卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在与Android和一些PhoneGap的code的最后一个星期,并通过周围的绊脚石打转转,已经相当成功地在我的应用程序的创建。

I've been playing around with android and some phonegap code for the last week and through stumbling around, have been quite successful in my application creation.

使用默认的启动画面我的应用程序加载,然后调用了各种JSON提要下载所有需要的数据的本地副本。在这一过程中它还会检查,看是否有闪屏图像(这是可编辑从CMS网站)的更新版本。如果有,则它下载它,并存储在SD卡。这完美的作品。

My app loads using a default splash screen and then calls out to various JSON feeds to download a local copy of all the data required. In doing this it also checks to see if there is an updated version of the splash screen image (Which is editable from a CMS website). If there is, then it downloads it and stores in on to the SD card. This works perfectly.

问题那么我是应用程序加载我想以显示新的闪屏的下一次。下列检查我的code,看是否较新的存在,但我不知道code到然后替换默认的新一:(

The problem I then have is the next time the app is loaded I want to show the new splash screen. My code below checks to see if the newer one exists but I don't know the code to then replace the default with the new one :(

我的code到目前为止是:

My code so far is:

package com.interdirect.Harlequin;

import java.io.File;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;

import com.phonegap.*; 

public class App extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 

    String newFolder = "/Harlequin";
    String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
    File appDirectory = new File(extStorageDirectory + newFolder);
    appDirectory.mkdirs();          
    File f = new File(extStorageDirectory + newFolder + "/Images/splash.jpg"); 
    if (f.exists()){     
        //USE THE FILE ABOVE AS THE SPLASH
    }else{       
        super.setIntegerProperty("splashscreen", R.drawable.splash);    
    }        
    super.loadUrl("file:///android_asset/www/index.html",2000);    


};
};

如果有人可以帮助上述这将是真棒,我拉我的头发上的东西,我甚至不知道是否有可能:(

If anyone could help on the above it would awesome as I'm pulling my hair out on something I don't even know if possible :(

推荐答案

您可以尝试这样的事情

Bitmap image = BitmapFactory.decodeFile(f);
ImageView splashScreen = (ImageView)findViewById(R.id.splashscreen);
splashScreen.setImageBitmap(image);

这篇关于Android的启动画面 - 图像从SD卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆