I want to show a toast on the screen when a certain condition is met in my static method, as shown below:
public static void setAuth(String a) { String[] nameparts1; if (a.trim().isEmpty()) { author = "Author Name"; firstinit1 = "Initial"; surname1 = "Surname"; } if (a == 'X') { Toast ifx = Toast.makeText(getApplicationContext(), "Please enter name in correct format.", Toast.LENGTH_SHORT); ifx.show(); } }
However, this gives me an error: "It is not possible to make a static reference to the non-static getApplicationContext () method from the ContextWrapper type."
Hope I have provided enough information here. Any help would be greatly appreciated!
source share