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
.现在假设我打开应用程序然后关闭它,它仍在运行,但在前台已关闭.
I am using webview
, and I'm appending some query string with the URL. Say URL is file:///android_asset/www/index.html
and I have added the query string ?urlid=MindTree_Projects&city=bangalore&firstTimeRule=%7B%22EEI....something
. So the whole URL looks like file:///android_asset/www/index.html?urlid=MindTree_Projects&city=bangalore&firstTimeRule=%7B%22EEI....something
. Now suppose I open the app and then close it, still its running, but in foreground its closed.
只有我能看到它在 chrome://inspect
中运行.这是调试网络应用的方法之一.
Only I can see it running in chrome://inspect
. Which is one of the way to debug web apps.
任何人都可以告诉我为什么会发生这种情况,这对我来说是值得的.
Can any body tell me why this is happening, it worth for me.
推荐答案
You may have to call the methods onPause()
and onResume()
of the WebView Class.
@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;
}
这篇关于android:关闭应用程序后它仍在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!