android:关闭应用程序后仍然运行

时间:2015-03-10 12:57:23

标签: android webview

我正在使用webview,我正在使用URL附加一些查询字符串。假设网址为file:///android_asset/www/index.html,我添加了查询字符串?urlid=MindTree_Projects&city=bangalore&firstTimeRule=%7B%22EEI....something。所以整个网址看起来像file:///android_asset/www/index.html?urlid=MindTree_Projects&city=bangalore&firstTimeRule=%7B%22EEI....something。现在假设我打开应用程序然后关闭它,仍在运行,但在前台关闭。

只有我可以看到它在chrome://inspect中运行。这是调试Web应用程序的方法之一。

任何人都可以告诉我为什么会这样,这对我来说很有价值。

1 个答案:

答案 0 :(得分:1)

您可能需要调用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;
}