Close the current activity when you only have a reference to Context

In my Case following worked,

I need to finish my activity in a AsyncTask onPostExcute().

Where my AsyncTask class is separate public class , which has a constructor with param of Context.

((Activity)(mContext)).finish();

Only the above worked for me... Anyway I got this idea from @2red13 and @lucy answers... Thanks to all...


yes, with a cast:

((Activity) ctx).finish();

I know it's an old post but, perhaps it could be a good idea to call it this way:

if(context instanceof Activity){
                ((Activity)context).finish(); }

This way we make sure we don't get any unnecesary ClassCastExceptions