Is there any way to use this keyword inside a static method in Java? I want to display a Toast message inside a static method in my activity class. How do I do that? Thanks.
Now what?
static void thisInStatic(){
new Object(){
Object instance = this;
};
}
You can create a static method with one input parameter that is the Class you need to use.
For example:
public static void showMyTouch(MyActivity act, String message){
Toast.makeText(act, message, Toast.LENGTH_LONG).show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With