android:关闭应用程序后它仍然 运行
android: after closing the app its still running
我正在使用 webview
,我正在使用 URL 附加一些查询字符串。假设 URL 是 file:///android_asset/www/index.html
,我添加了查询字符串 ?urlid=MindTree_Projects&city=bangalore&firstTimeRule=%7B%22EEI....something
。所以整个 URL 看起来像 file:///android_asset/www/index.html?urlid=MindTree_Projects&city=bangalore&firstTimeRule=%7B%22EEI....something
。现在假设我打开应用程序然后关闭它,它仍然是 运行,但在前台它已关闭。
只有我 运行 在 chrome://inspect
中看到它。这是调试 Web 应用程序的方法之一。
谁能告诉我为什么会这样,这对我来说很有价值。
您可能需要调用 WebView Class 的方法 onPause()
和 onResume()
。
@Override
protected void onPause()
{
super.onPause();
mWebView.onPause(); // pauses the WebView (JavaScript, flash etc.)
}
@Override
protected void onResume()
{
super.onResume();
mWebView.onResume(); // resumes the WebView (JavaScript, flash etc.)
}
@Override
protected void onDestroy()
{
super.onDestroy();
relativeLayoutPlaceholder.removeView(mWebView); // removes the WebView from its Placeholder
mWebView.destroy(); // destroys the WebView
mWebView = null;
}
我正在使用 webview
,我正在使用 URL 附加一些查询字符串。假设 URL 是 file:///android_asset/www/index.html
,我添加了查询字符串 ?urlid=MindTree_Projects&city=bangalore&firstTimeRule=%7B%22EEI....something
。所以整个 URL 看起来像 file:///android_asset/www/index.html?urlid=MindTree_Projects&city=bangalore&firstTimeRule=%7B%22EEI....something
。现在假设我打开应用程序然后关闭它,它仍然是 运行,但在前台它已关闭。
只有我 运行 在 chrome://inspect
中看到它。这是调试 Web 应用程序的方法之一。
谁能告诉我为什么会这样,这对我来说很有价值。
您可能需要调用 WebView Class 的方法 onPause()
和 onResume()
。
@Override
protected void onPause()
{
super.onPause();
mWebView.onPause(); // pauses the WebView (JavaScript, flash etc.)
}
@Override
protected void onResume()
{
super.onResume();
mWebView.onResume(); // resumes the WebView (JavaScript, flash etc.)
}
@Override
protected void onDestroy()
{
super.onDestroy();
relativeLayoutPlaceholder.removeView(mWebView); // removes the WebView from its Placeholder
mWebView.destroy(); // destroys the WebView
mWebView = null;
}