Close activity from another class

I have a question in Android while building my Google Maps app.

I have one action as below

public class MapCallActivity extends MapActivity {
    classA class = new classA(this);
    classA.callMethod();
}

classA defined as follows:

 public class classA{
   public classA(Context context){
   this.myContext = context;
 }

   void callMethod(){
      if (isFileValid) {
        <do_something...>;
      } else {
        <call_the_activity finish() method>;
      }
   }
 }   

Is there a way I can do <call_the_activity finish() method>to MapCallActivityclose?

Any help is appreciated!

+5
source share
1 answer
public class classA{
    public classA(Context context){
        this.myContext = context;
    }

    void callMethod(){
        if(isFileValid){

        }else{
            ((Activity)myContext).finish();
        }
    }
}
+27
source

All Articles