I'm looking for a good example, how I can call a method that is declared in MainAcitivity from another class in the same package.
I have a getSMS method in MainAcitivity class, that looks like as following:
    private void sendSMS(String phoneNumber, String message) {
            SmsManager sms = SmsManager.getDefault();
            sms.sendTextMessage(phoneNumber, null, message, null, null);
        }
public void getSMS(){
            sendSMS("5556", "You're at home.");
    }
I'm calling getSMS() method in another class from MainActivity class.
public void tSMS(){
    MainActivity mainActivity = new MainActivity();
    mainActivity.getSMS();
}
Now I'm calling the method in other class using the conditional statement.
            if (activity.getType() == 3) {
            tSMS();
                }
Logcat:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
 
    