How to enable cookies for Android phonegap 1.8.0 app?

后端 未结 3 813
臣服心动
臣服心动 2020-12-15 14:43

I understood that in order to use cookies inside of phonegap native app there must be piece of code which enables it.

When building phonegap for iOS using xcode 4 th

3条回答
  •  情话喂你
    2020-12-15 15:39

    If my memories are good, the Phonegape's template loads your start-up web page (ex: index.html) by loading it from the webview (something like : super.loadUrl("file:///android_asset/www/index.html");). The latter is declared in the main activity (a ".java" file).

    So, first, find the instruction that loads your web application. Then, add the following lines before the webview.loadUrl so that you can obtain something like this :

    CookieSyncManager.createInstance(this);
    CookieSyncManager.getInstance().startSync();
    webView = (WebView) findViewById(R.id.webview);
    webview.getSettings().setJavaScriptEnabled(true);
    super.loadUrl("file:///android_asset/www/index.html");
    

    Finally, refresh the Android's project and relunch the app.

提交回复
热议问题