litesoft
@ 729
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
package org.litesoft.droid; import org.apache.cordova.*; import android.content.res.AssetManager; import android.os.Bundle; public class PhoneGapActivity extends DroidGap { /** * Called when the activity is first created. */ @Override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); loadUrl( "file:///android_asset/www/" + findIndexHtml( getValue("language", "en") ) ); } private String getValue( String key, String defaultValue ) { return getSharedPreferences( getApplicationInfo().packageName, MODE_PRIVATE ).getString( key, defaultValue ); } private String findIndexHtml( String language ) { AssetManager assetManager = getAssets(); try { String[] files = assetManager.list( "www" ); if ( files != null ) { String toFind = "index-" + language + ".html"; for ( String file : files ) { if ( toFind.equals( file ) ) { return file; } } } } catch ( Exception e ) { // Fall Thru } return "index.html"; } } |