Note, that you will need the whole code from the question too.
In addition to my solution inside background activity (or just base activity of your application) I added:
private FrameLayout touchInterceptor;
@Override
protected void onPause() {
if (touchInterceptor.getParent() == null) {
((ViewGroup) findViewById(android.R.id.content)).addView(touchInterceptor);
}
super.onPause();
}
@Override
protected void onResume() {
((ViewGroup) findViewById(android.R.id.content)).removeView(touchInterceptor);
super.onResume();
}
And in the onCreate()
:
// For intercepting clicks from dialog like activities
touchInterceptor = new FrameLayout(this);
touchInterceptor.setClickable(true);
Now works like a charm! :)