codingmonk21
codingmonk21

Reputation: 83

Unable to call getLifecycle() method in AppCompatActivity

I am trying to test the android architecture components and have included the libraries for the same in the app.

Going through the sample code in google documentation it has a method getLifecycle() that is being passed to another class. But I'm not able to call that method from the main activity that extends AppCompatActivity. The auto suggestion wont show up the method. Am I missing something?

Upvotes: 1

Views: 4037

Answers (1)

guglhupf
guglhupf

Reputation: 1348

Do you have Support Library 26.1.0 or later in your gradle file? Because as stated here:

Fragments and Activities in Support Library 26.1.0 and later already implement the LifecycleOwner interface.

If you have the corresponding support library, the AppCompatActivity should have the getLifecycle() method available.

Upvotes: 8

Related Questions