gkapellmann
gkapellmann

Reputation: 323

Invoke a main class method from other class in Android

So I don't know if this is possible, so in more detail:

I have my main class public class MainAR extends Activity{ and an object GUIManager of other class. From that other I want to call a method from MainAR:

public class MainAR extends Activity{
    ...
    private GUIManager mGUIManager;
    ...
    mGUIManager = new GUIManager(getApplicationContext());
    ...
    public void mehtodMain(){
        ...
    }
}

And then the other class:

public class GUIManager {
    private MainAR mainClass;

    public GUIManager(Context context){
        //mainClass = ???
        ...
    }

    private method(){
        mainClass.mehtodMain();
    }
}

But I have no idea how to initialize mainClass...

Upvotes: 0

Views: 79

Answers (1)

r2DoesInc
r2DoesInc

Reputation: 3771

Provide it an instance of your main class

mGUIManager = new GUIManager(MainAR.this);

public GUIManager(MainAR mainClass){
        this.mainClass = mainClass;
    }

Upvotes: 1

Related Questions