Fix cannot resolve method ‘getActivity() in Android Java

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

  1. this
  2. MainActivity.this

Don’t forget to rename the MainActivity with the name of your Activity

Post navigation

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.