Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

lint

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?

like image 400
Alireza Akbari Avatar asked Nov 12 '16 10:11

Alireza Akbari


1 Answers

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

like image 94
rastik Avatar answered Oct 07 '22 21:10

rastik