Abraham
Abraham

Reputation: 561

Compiled SDK different from the source?

I'm trying to use the DialogListener interface inside the class WifiP2pManager (android.net.wifi.p2p.WifiP2pManager.DialogListener) in API17 (removed in API18 and API19). In the source code of Android it is shown as "Public" (WifiP2pManager.java):

 /**
 * Interface for callback invocation when dialog events are received.
 * see {@link #setDialogListener}.
 * @hide
 */
public interface DialogListener {

    /**
     * Called by the system when a request to show WPS pin is received.
     *
     * @param pin WPS pin.
     */
    public void onShowPinRequested(String pin);

    /**
     * Called by the system when a request to establish the connection is received.
     *
     * Application can then call {@link #connect} with the given config if the request
     * is acceptable.
     *
     * @param device the source device.
     * @param config p2p configuration.
     */
    public void onConnectionRequested(WifiP2pDevice device, WifiP2pConfig config);

    /**
     * Called by the system when this listener was attached to the system.
     */
    public void onAttached();

    /**
     * Called by the system when this listener was detached from the system or
     * failed to attach.
     *
     * Application can request again using {@link #setDialogListener} when it is
     * in the foreground.
     *
     * @param reason The reason for failure could be one of {@link #ERROR},
     * {@link #BUSY}, {@link #P2P_UNSUPPORTED} or {@link #NOT_IN_FOREGROUND}
     */
    public void onDetached(int reason);
}

But in the compiled class inside the SDK it is not shown, if you look inside android.jar, WifiP2pManager.class you won't find, therefore when trying to using it in my Activity it shows me the error "Cannot resolve symbol".

What I am missing?

Upvotes: 0

Views: 240

Answers (1)

doorstuck
doorstuck

Reputation: 2308

In the source you can see the annotation @hide above the interface and methods related to it:

 /**
 * Interface for callback invocation when dialog events are received.
 * see {@link #setDialogListener}.
 * @hide
 */
public interface DialogListener {

This means that the thing under it is hidden and not accessible in the public API.

The Android developers does not want you to use it. You might want to look for other alternatives. Since it's not part of the public API you cannot rely on your users having access to it and you app will fail for those users if you try to circumvent it.

Upvotes: 1

Related Questions