Android: Guardar XWalkView – Estado de la pasarela

Estoy utilizando XWalkView para mostrar un sitio web móvil como una aplicación. Mi problema es cuando la aplicación va de fondo y vuelve a recargar la página que muestra. Quiero mantenerlo estado y continuar de ese estado cuando viene de fondo. Aquí está mi código:

public class MainActivity extends AppCompatActivity { static final String URL = "https://www.biletdukkani.com.tr"; static final int MY_PERMISSIONS_REQUEST_ACCESS_LOCATION = 55; static final String SHOULD_ASK_FOR_LOCATION_PERMISSION = "shouldAskForLocationPermission"; static final String TAG = "MainActivity"; static final String COMMAND = "/system/bin/ping -c 1 185.22.184.184"; static XWalkView xWalkWebView; TextView noInternet; static Bundle stateBundle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate"); // Check whether we're recreating a previously destroyed instance if (savedInstanceState != null) { // Restore value of members from saved state stateBundle = savedInstanceState.getBundle("xwalk"); } setContentView(R.layout.activity_main); initNoInternetTextView(); } public void onRestoreInstanceState(Bundle savedInstanceState) { // Always call the superclass so it can restore the view hierarchy super.onRestoreInstanceState(savedInstanceState); stateBundle = savedInstanceState.getBundle("xwalk"); Log.d(TAG, "onRestoreInstanceState"); } /** * İnternet yok mesajı gösteren TextVidew'i ayarlar. */ private void initNoInternetTextView() { Log.d(TAG, "initNoInternetTextView"); noInternet = (TextView) findViewById(R.id.no_internet); if (noInternet != null) { noInternet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { checkInternetConnection(); } }); } } /** * WebView'i ayarlar. */ private void initWebView() { Log.d(TAG, "initWebView"); if (xWalkWebView == null) { ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar); xWalkWebView = (XWalkView) findViewById(R.id.webView); //xWalkWebView.clearCache(true); xWalkWebView.load(URL, null); xWalkWebView.setResourceClient(new BDResourceClient(xWalkWebView, progressBar)); } } @Override protected void onResume() { super.onResume(); Log.d(TAG, "onResume"); checkLocationPermissions(); checkInternetConnection(); if (xWalkWebView != null && stateBundle != null) { xWalkWebView.restoreState(stateBundle); } } @Override protected void onPause() { super.onPause(); Log.d(TAG, "onPause"); if (xWalkWebView != null) { stateBundle = new Bundle(); xWalkWebView.saveState(stateBundle); } } public void onSaveInstanceState(Bundle savedInstanceState) { Log.d(TAG, "onSaveInstanceState"); // Save the user's current game state savedInstanceState.putBundle("xwalk", stateBundle); // Always call the superclass so it can save the view hierarchy state super.onSaveInstanceState(savedInstanceState); } @Override public void onBackPressed() { Log.d(TAG, "onBackPressed"); if (xWalkWebView != null && xWalkWebView.getNavigationHistory().canGoBack()) { xWalkWebView.getNavigationHistory().navigate(XWalkNavigationHistory.Direction.BACKWARD, 1); } else { super.onBackPressed(); } } } 

También he intentado añadir las siguientes líneas para manifestar pero no funcionó.

 android:launchMode="singleTask" android:alwaysRetainTaskState="true" 

¿Cómo puedo hacer eso? Gracias en advcance.

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.