tied core file name to applicationCode value stored in AndroidManifest.xml

This commit is contained in:
techdragon.nguyen@gmail.com
2012-04-18 14:45:05 +00:00
parent bd9dc97ee0
commit e447a9c48d
@@ -22,6 +22,7 @@ import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.hardware.Sensor; import android.hardware.Sensor;
@@ -81,7 +82,7 @@ public class SDLActivity extends Activity implements OnKeyListener{
public String mErrorMessage = ""; public String mErrorMessage = "";
public Boolean mErrorHappened = false; public Boolean mErrorHappened = false;
public final static String RES_FOLDER = "/sdcard/Wagic/Res/"; public final static String RES_FOLDER = "/sdcard/Wagic/Res/";
public static final String RES_FILENAME = "core_0182.zip"; public static String RES_FILENAME = "core_0184.zip";
public static final String RES_URL = "http://wagic.googlecode.com/files/"; public static final String RES_URL = "http://wagic.googlecode.com/files/";
public String systemFolder = "/sdcard/Wagic/Res/"; public String systemFolder = "/sdcard/Wagic/Res/";
@@ -433,6 +434,9 @@ public class SDLActivity extends Activity implements OnKeyListener{
// So we can call stuff from static callbacks // So we can call stuff from static callbacks
mSingleton = this; mSingleton = this;
mContext = this.getApplicationContext(); mContext = this.getApplicationContext();
// get the current version of the app to set the core filename
String versionCodeString = getApplicationCode();
RES_FILENAME = "core_" + versionCodeString + ".zip";
StorageOptions.determineStorageOptions(); StorageOptions.determineStorageOptions();
checkStorageLocationPreference(); checkStorageLocationPreference();
@@ -773,8 +777,17 @@ public class SDLActivity extends Activity implements OnKeyListener{
return false; return false;
} }
private String getApplicationCode()
{
int v = 0;
try {
v = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch (NameNotFoundException e) {
// Huh? Really?
v = 184; // shouldn't really happen but we need to default to something
}
return "0" + v;
}
} }
/** /**