How do I call the method startChronometer
in another class when the method is declared inside the main activity?
Inside MainActivity
:
public void startChronometer() {
mChronometer.start();
showElapsedTime();
}
Inside another class, I tried to do this:
MainActivity mActivity;
mActivity.startChronometer();
But an error occurred which said:
java.lang.NullPointerException.
May I know what more I need to add to the code?