大家好我在我的日志猫中得到这个错误,我不知道如何解决..
android.app.ServiceConnectionLeaked: Activity com.example.harrops.h20droidapp.webstreamsListview has leaked ServiceConnection azy@236e1451 that was originally bound here
我有一个列表视图,当单击一个项目时,它会打开该项目的webview。我也有一个webclient为此设置,因为我需要网页有自己的自定义加载对话框,如果它打开某些链接,它将在工厂浏览器中打开它们。任何帮助或煽动正在发生的事情将不胜感激
这是我的webstreamsListview
@Override
public void onSaveInstanceState(Bundle outState) {
wv.saveState(outState);
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webstreams_listview);
if (savedInstanceState == null) {
mAdView = (AdView) findViewById(R.id.webstreams_adview);
mAdView2 = (AdView) findViewById(R.id.webstreams_adview1);
lv = (ListView) findViewById(R.id.lvWebstreamingSites);
lv.setScrollbarFadingEnabled(false);
lv.setAdapter(new webStreamsAdapter(this));
wv = (WebView) findViewById(R.id.wvWebStreamingSites);
final AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mAdView.loadAd(adRequest);
lv.setOnItemClickListener(new CastingOnitemListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
wv.setScrollbarFadingEnabled(false);
wv.getSettings().setJavaScriptEnabled(true);
wv.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
wv.getSettings().setRenderPriority(WebSettings.RenderPriority.NORMAL);
wv.getSettings().setLoadsImagesAutomatically(true);
wv.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
if (Build.VERSION.SDK_INT >= 19) {
// chromium, enable hardware acceleration
wv.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
// older android version, disable hardware acceleration
wv.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
wv.canGoBackOrForward(1);
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
wv.setPadding(0, 0, 0, 0);
wv.setWebViewClient(new webclient1(dialog, c));
wv.loadUrl(MY URL);
break;
这是我的webclient类
public class webclient1 extends WebViewClient {
View v;
ProgressDialog dg;
public webclient1(ProgressDialog dialog, Context c) {
this.dg = dialog;
dg = new ProgressDialog(c,R.style.CustomDialog);
dg.setTitle("H20 its an app thing ...");
dg.setIcon(R.drawable.h20_dialog_logo);
dg.setMessage("Please wait...");
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String urlNewString) {
webView.getSettings().setSupportMultipleWindows(true);
webView.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(urlNewString)));
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
view.setVisibility(View.GONE);
dg.show();
}
@Override
public void onPageFinished(WebView view, String url) {
view.setVisibility(View.VISIBLE);
dg.dismiss();
}
}
答案 0 :(得分:0)
好的家伙我认为这是因为我的自定义webclient在webview关闭后仍然传递服务这是我如何修复它。
我在我的webstreamslistview类中执行了这个void方法,一旦网页被销毁就会清除所有内容
@Override
protected void onDestroy() {
super.onDestroy();
wv.removeAllViews();
wv.clearHistory();
wv.clearCache(true);
wv.clearView();
wv.destroy();
wv= null;
}