Search code examples
javaandroidjavadocandroid-preferences

Why is DialogPreference.needInputMethod() hidden?


According to DialogPreference.java:

Returns whether the preference needs to display a soft input method when the dialog is displayed. Default is false. Subclasses should override this method if they need the soft input method brought up automatically.

However, it has the @hide tag, and is not visible in the SDK. Nevertheless, subclasses of DialogPreference still implement it:

My questions:

  1. Why is there @hide?
  2. If I am extending DialogPreference and want the soft keyboard to be shown, should I implement it?

Solution

  • As a general rule of thumb, hidden APIs are not supposed to be implemented. The reason for this might be that the API is under development and might be changed, the API is for internal use only, Unstable etc...

    In this case, you are right that the EditTextPreference.java class is directly invoking this method, but you shouldn't conclude that this means that other subclasses should do the same.

    In fact, if you examin the commit message of the developer that added this method to the class, you see that:

    changeset: 1d458570757e607f0dc11fb0e963017916ac0701

    summary: Show keyboard automatically in EditTextPreferences dialogs

    User: ...

    Date: Tue Sep 15 19:25:51 CEST2009

    So, it seems that this method is intended to be used by EditTextPreferences and not by others.