Connectoin to server failed on phone

I use phonegap when I tried to load the html file, get this error

The connection to the server was unsuccessful. (file: ///android_asset/www/index.html)

My code is:

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; } } 
+4
source share
1 answer

The problem is most likely related to the speed of the emulator or device, the network is too slow to complete the connection in standard time.

use super.setIntegerProperty ("loadUrlTimeoutValue", 60000); before calling super.loadUrl ("file: ///android_asset/www/index.html");

it sets a 60 second timeout to complete the connection.

he works for me.

+3
source

Source: https://habr.com/ru/post/1443434/


All Articles