2013年3月25日 星期一

解決"The connection to the server was unsuccessful"的問題

Android的PhoneGap專案有可能會遇到"The connection to the server was unsuccessful"此一錯誤訊息,解決方法是在MainActivity.java檔的onCreate()內盡可能加大timeout時間,如下:

1
2
3
4
5
6
7
8
9
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        
    // 解決 "The connection to the server was unsuccessful" 的問題
    super.setIntegerProperty("loadUrlTimeoutValue", 900000000); 
        
    super.loadUrl("file:///android_asset/www/index.html" );
}



沒有留言:

張貼留言