Kamran Akbary
Kamran Akbary

Reputation: 2993

Android, This API is marked as internal to the support library and should not be accessed from apps error

I'm using invalidateOptionsMenu() method to handle changing toolbar MenuItems but recently lint is highlight this method as an ERROR and says:

This API is marked as internal to the support library and should not be accessed from apps

Also for navigationview.setNavigationItemSelectedListener(XXX); method and some others! It's very illogical to use @SuppressWarnings("RestrictedApi") for solving this problem, because you are just ignoring the lint but not solving the problem.

how can I fix this issue?

Upvotes: 12

Views: 2947

Answers (1)

rastik
rastik

Reputation: 2576

If you're using support library and AppCompatActivity, you should call supportInvalidateOptionsMenu.

Upvotes: 4

Related Questions