I have HTML page for design and implementation for some function. When i launch the app i load one HTML file from assets folder. In this Activity i have index.html page. Here when i click the button it goes to about page. If close the app, and open it shows the about page. Why it's not loading index page.
code:
public class MainActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Runnable rn =new Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
OnDestroy();
}
};
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 3000);
}
public void OnResume(){
super.loadUrl("file:///android_asset/www/index.html", 3000);
}
public void OnDestroy(){
try {
trimCache(this);
Toast.makeText(this,"onDestroy " ,Toast.LENGTH_LONG).show();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void trimCache(Context context) {
try {
File dir = context.getCacheDir();
Toast.makeText(context, "Delete", Toast.LENGTH_SHORT).show();
if (dir != null && dir.isDirectory()) {
deleteDir(dir);
}
} catch (Exception e) {
// TODO: handle exception
}
}
public static boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
return dir.delete();
}
while using on Resume error logcat:
09-26 13:07:11.360: D/CordovaLog(326): file:///android_asset/www/js/script.js: Line 60 : 415
09-26 13:07:11.360: I/Web Console(326): 415 at file:///android_asset/www/js/script.js:60
09-26 13:07:11.590: E/CordovaWebView(326): CordovaWebView: TIMEOUT ERROR!
09-26 13:07:11.610: D/Cordova(326): CordovaWebViewClient.onReceivedError: Error code=-6 Description=The connection to the server was unsuccessful. URL=file:///android_asset/www/index.html
09-26 13:07:11.661: D/CordovaActivity(326): onMessage(onReceivedError,{"errorCode":-6,"url":"file:\/\/\/android_asset\/www\/index.html","description":"The connection to the server was unsuccessful."})
09-26 13:07:12.250: D/Cordova(326): onPageFinished(file:///android_asset/www/index.html)
09-26 13:07:12.250: D/CordovaActivity(326): onMessage(onPageFinished,file:///android_asset/www/index.html)
09-26 13:07:12.270: D/SoftKeyboardDetect(326): Ignore this event
If i didn't use onResume method i got this erro:
09-26 13:34:50.060: I/CordovaLog(824): Found start page location: index.html
09-26 13:34:50.071: I/CordovaLog(824): Changing log level to DEBUG(3)
09-26 13:34:50.090: D/CordovaActivity(824): Resuming the App
09-26 13:34:50.090: D/CordovaActivity(824): CB-3064: The errorUrl is null
09-26 13:34:50.160: D/CordovaLog(824): : Line 1 : exception firing resume event from native
09-26 13:34:50.171: I/Web Console(824): exception firing resume event from native at :1