title: Is it safe to use @SuppressLint("RestrictedApi") with AndroidX libraries?
body: <p>I would like to now whether it is safe or not to use @SuppressLint(&quot;RestrictedApi&quot;) annotation. I am pretty sure that the answer is NO, so I want to ask why as well.</p>
  <p>I guess that the development team wanted to hide such <code>restricted code</code> from the API users. Probably due to changes in the future or because the code is intended to work as internal functionality</p>
  <p>Example code with <code>androidx.preference:preference:1.1.1</code>:</p>
  <pre><code>public abstract class CustomAdapterPreferenceFragment extends PreferenceFragmentCompat {
  
      @Override
      protected PreferenceGroupAdapter onCreateAdapter(PreferenceScreen preferenceScreen) {
          // this annotation removes warning that says PreferenceGroupAdapter can only be called from package names that start with androidx.preference        
          @SuppressLint(&quot;RestrictedApi&quot;)
          final PreferenceGroupAdapter adapter = new PreferenceGroupAdapter(preferenceScreen) {
              @Override
              public void onBindViewHolder(PreferenceViewHolder holder, int position) {
                  super.onBindViewHolder(holder, position);
              }
          };
          return adapter;
      }
  </code></pre>
  <p>Link to annotation that restricts code usage in this example: <a href="https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/preference/preference/src/main/java/androidx/preference/PreferenceGroupAdapter.java#47" rel="nofollow noreferrer">AOSP AndroidX</a></p>