Reputation: 41
i am using phonegap,when i tried to load html file get this error
The connection to the server was unsuccessful. (file:///android_asset/www/index.html)
My code:
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import android.view.Menu;
public class LoadHtml extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.loadUrl("file:///android_asset/www/index5.html");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_first, menu);
return true;
}
}
Upvotes: 4
Views: 1103
Reputation: 405
The problem is likely due to the speed of the emulator or device, the network is too slow for completing the communication in a default time.
use super.setIntegerProperty("loadUrlTimeoutValue", 60000); before calling super.loadUrl("file:///android_asset/www/index.html");
it sets a 60 second timeout for completing the communication.
it works for me.
Upvotes: 3