How to catch touch event of a dialog when it is clicked outside

android

Solution

The second answer on this thread shows how to do this (used it myself, works):

How to cancel an Dialog themed like Activity when touched outside the window?

Problem

I have `Dialog` in my activity, what I want is suppose the dialog is open, then on Touch of outside dialog I want to dismiss the dialog, and at the same time, I want to call a function which does some update in my activity. Initially I used `MyDialog.setCanceledOnTouchOutside(true);` But these will only dismiss and in my case, at the same time I want to call some functions whenever user click outside of a dialog. So what should I do? I know that if I can extend the `Dialog` class and override its `onTouchEvent` method then it will be solved but in my case, my class already extends Activity class and in java, we can't extend more then one class. So what will be the best solution for that? Please help me to solve this out.

Original source

Related problems