Hi all,
I'm using the embedded Android SDK in our application. Everything is
working fine, except when we have a new activity due to a rotation change.
First I tried to work with the methods saveState and restoreState by
retaining the bundle given by this methods. The page is reloaded, but not
the whole state (executed JS-methods for instance in a single page
application). I have the feeling that the url is just reloaded.
Secondly I tried to retain the view itself through activities. The first
time the page is rendered well. After activity recreation the view is gone.
With a normal WebView this way of working is working well. Why it isn't
working with Crosswalk?
Here is the sample code for crosswalk:
public class MainActivity extends Activity {
private static XWalkView crosswalk;
private static boolean newView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
newView = false;
if (crosswalk == null) {
crosswalk = new XWalkView(this);
newView = true;
}
ViewGroup viewGroup = (ViewGroup) findViewById(R.id.test);
if (!newView) {
((ViewGroup)crosswalk.getParent()).removeView(crosswalk);
}
viewGroup.addView(crosswalk);
}
@Override
protected void onResume() {
super.onResume();
if (newView) {
crosswalk.load("http://www.google.be", null);
}
}
}
Below you can find the working version for the default WebView:
public class WebViewActivity extends Activity {
private static WebView webview;
private static boolean newView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
newView = false;
if (webview == null) {
webview = new WebView(this);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
newView = true;
}
ViewGroup viewGroup = (ViewGroup) findViewById(R.id.test);
if (!newView) {
((ViewGroup)webview.getParent()).removeView(webview);
}
viewGroup.addView(webview);
}
@Override
protected void onResume() {
super.onResume();
if (newView) {
webview.loadUrl("http://www.google.be");
}
}
}
Thanks,
Kind regards,
Jo
_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help