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.
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.
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 :(
My code so far is:
package com.interdirect.Harlequin;
开发者_JAVA技巧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 :(
You can try something like this
Bitmap image = BitmapFactory.decodeFile(f);
ImageView splashScreen = (ImageView)findViewById(R.id.splashscreen);
splashScreen.setImageBitmap(image);
精彩评论