I’m trying to finish my class which extends FragmentActivity from a static method:-
private static void myFinish(Context context,Activity activity) {
[some code]
activity.finish();
}
From this method:-
private static void remove(Context context) {
myFinish(context, ((Activity) context).getParent());
}
This code compiles but gives me an error :-
java.lang.ClassCastException: android.app.Application cannot be cast to android.app.Activity
How can I solve this?
I found a simple solution.
Declare:
In onCreate:
then
does the work.