Search code examples
androidwebviewondestroy

app destroy code editing


I want to destroy the webview and start airpush ads in my app on app exit.Is this a stable way or should I combine them together

    public void onDestroy()
{
    if (mWebView != null)
    {
        mWebView.removeAllViews();

        mWebView.destroy();
    }
    super.onDestroy();
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
airpush.startAppWall();
airpush.startDialogAd();
airpush.startLandingPageAd();
finish();
}
return super.onKeyDown(keyCode, event);
}

Solution

  • I don't see why you would even override onKeyDown if you are just going to finish();

    Just combine them in onDestroy. Unless I am missing something, your post is fairly vague.

    Also, just on a personal note, I immediately uninstall your app if it posts ads to my notification bar. I'm not sure if that is what this does, but I know airpush is notorious for that. Just a heads up, Some people don't like that.