I am writing a game with javascript. This application works well in my browser (fast), but I have some problems running this with an Android web browser.
- Application startup time takes 5 seconds or more (I think this is a slow process, but maybe this is normal?)
In the game menu, I have a method like:
this.showCredits = function() {
document.getElementById('core-credits-layer').style.display = 'block';
document.getElementById('core-credits').style.display = 'block';
var parent = this;
$.ajax({
url: 'content/credits.html',
dataType: 'html',
success: function(data, status, response) {
var now = new Date();
var s = now.getSeconds()-parent.test.getSeconds();
console.log('success ajax: '+s);
document.getElementById('core-credits').scrollTop = 0;
document.getElementById('core-credits').innerHTML = response.responseText;
console.log('finished');
},
error: function() {
console.error('failed fetch credits');
}
});
}
So, the console log ("finished", the last line in success ()), immediately after clicking the "loans" menu. But it can take 6 seconds (more or less) until I see the div # core-credits. In my browser, I see # core-credits right after clicking. But the second time, by clicking on this menu point, I get a div after 1-2. Iβm not sure what it is now, I donβt think itβs caching because I quickly switch to callback ().
Java:
public void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Context context = this.getApplicationContext();
SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);
boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true);
if(isFirstRun) {
this.copyAudioFiles(context);
}
WebView mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
String data = context.getFilesDir().getPath();
mWebView.getSettings().setDatabasePath(data+"data/"+this.getPackageName()+"/databases/");
mWebView.getSettings().setAllowFileAccess(true);
mWebView.setWebChromeClient(new WebChromeClient());
String data_root = Environment.getExternalStorageDirectory()+"/"
+this.getPackageName();
mWebView.loadUrl("file:///android_asset/www/index.html?system=android&" +
"data_root="+data_root);
}
eclipse, asus.
(jquery show ('slow')) . ( ), 9 ( "" ), 3 8 , 9 ^^.
, firefox.
Android 4.1.
. webview, , .