Close the current activity when you only have a reference to Context
If I have a reference to Context
, is it possible to finish the current activity?
I don't have the reference to current activity.
yes, with a cast:
((Activity) ctx).finish();
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...