InitLipton
InitLipton

Reputation: 2453

Do i need to use AppCompatActivity for Android M

I've to update an app to android version 6 to incorporate the new permissions functionality. but all the examples i see use AppCompatActivity.

https://blog.xamarin.com/requesting-runtime-permissions-in-android-marshmallow/

The app I'm updating' base class inherits from Activity. If i change this to use AppCompatActivity, the cascading effect is quite big. for one the OnMenuItemSelected(int featureId, IMenuItem item) is now sealed and i have to change to using OnOptionsItemSelected instead, and issues with the Themes.

Is it possible to use Activity as the base class and still request permissions in android 6. If so, is there an example, they all seem to use AppCompatActivity

Upvotes: 0

Views: 559

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93678

It is, but you'll need to not call that API in any version of the framework below M. So that means you'll need to write a function that checks the version and conditionally calls the request or not based on build id.

In general I think its best to use the compat version of any class in the compat library. It tends to cause less pain down the road as new versions roll out.

Upvotes: 1

Related Questions