Question

I'm trying to create a static utility class which will contain simple functions like Messagebox(AlertDialog), EmailSender, etc... and will call these functions on other activites. But as I understand I can not create a static class if it is not in a class. What do you suggest for this kind of utility classes?

Was it helpful?

Solution

Why not make it that way

class Utils{
    public static void makeToast(Context context, String text){
        Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
    }
}

In your activity call it this way

Utils.makeToast(this,"hi");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top