How to Fix Cannot resolve method ‘getActivity() in Android Studio Java
This error is common and it has occurred in your code because it is an obsolete (old) java code, you need alternative of the code which are given below
So if you face this error cannot resolve method ‘getActivity() in android studio, you can replace it with one of the alternatives below
this
MainActivity.this
-
getApplicationContext();
Don’t forget to rename the
[contact-form][contact-field label=”Name” type=”name” required=”true” /][contact-field label=”Email” type=”email” required=”true” /][contact-field label=”Website” type=”url” /][contact-field label=”Message” type=”textarea” /][/contact-form]
MainActivity with the name of your Activity