'Android call method from another class without canvas reference

I have a method:

 private void  setDir(Canvas canvas, Direction direction) {
...
}

This method is called in the overriden protected void onDraw(Canvas canvas) function. It is able to receive the canvas used in the onDraw.

Now I want to call this method from another class. But I cannot pass in the canvas because I do not know how to get it.

How can I call this method from another class without passing canvas variable? I have tried to make the canvas a class member, but it just crashes my app when I invoke the function



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source