By adding CookieSyncManager onCreate of Activity and also on corresponding events like onPause and onResume, taking care my session ID for the PHP server when the Activity/WebView reloads.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().startSync();
WebView myWebView = ((WebView)findViewById(R.id.webview));
myWebView.setWebViewClient(new WebViewClient());
}
@Override
protected void onResume() {
super.onResume();
CookieSyncManager.getInstance().stopSync();
}
@Override
protected void onPause() {
super.onPause();
CookieSyncManager.getInstance().sync();
}
}
1 comment:
it works thank you very much
Post a Comment