Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#pubctors) \| [Methods](https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#inhmethods)

# PasswordCallback


`
public


class
PasswordCallback
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/javax/security/auth/callback/Callback,

https://developer.android.com/reference/java/io/Serializable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.security.auth.callback.PasswordCallback |

<br />

*** ** * ** ***

<br />

Underlying security services instantiate and pass a
`PasswordCallback` to the `handle`
method of a `CallbackHandler` to retrieve password information.
**See also:**

- `https://developer.android.com/reference/javax/security/auth/callback/CallbackHandler`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#PasswordCallback(java.lang.String,%20boolean)(https://developer.android.com/reference/java/lang/String prompt, boolean echoOn) ` Construct a `PasswordCallback` with a prompt and a boolean specifying whether the password should be displayed as it is being typed. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#clearPassword()() ` Clear the retrieved password. |
| ` char[]` | ` https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#getPassword()() ` Get the retrieved password. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#getPrompt()() ` Get the prompt. |
| ` boolean` | ` https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#isEchoOn()() ` Return whether the password should be displayed as it is being typed. |
| ` void` | ` https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#setPassword(char[])(char[] password) ` Set the retrieved password. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### PasswordCallback

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PasswordCallback (String prompt, 
                boolean echoOn)
```

Construct a `PasswordCallback` with a prompt
and a boolean specifying whether the password should be displayed
as it is being typed.

<br />

<br />

| Parameters ||
|---|---|
| `prompt` | `String`: the prompt used to request the password. <br /> |
| `echoOn` | `boolean`: true if the password should be displayed as it is being typed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `prompt` is null or if `prompt` has a length of 0. |

## Public methods

### clearPassword

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void clearPassword ()
```

Clear the retrieved password.

<br />

### getPassword

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public char[] getPassword ()
```

Get the retrieved password.

This method returns a copy of the retrieved password.

<br />

<br />

| Returns ||
|---|---|
| `char[]` | the retrieved password, which may be null. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#setPassword(char[])`

### getPrompt

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getPrompt ()
```

Get the prompt.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the prompt. <br /> |

### isEchoOn

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isEchoOn ()
```

Return whether the password
should be displayed as it is being typed.

<br />

<br />

| Returns ||
|---|---|
| `boolean` | the whether the password should be displayed as it is being typed. <br /> |

### setPassword

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setPassword (char[] password)
```

Set the retrieved password.

This method makes a copy of the input *password*
before storing it.

<br />

<br />

| Parameters ||
|---|---|
| `password` | `char`: the retrieved password, which may be null. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/security/auth/callback/PasswordCallback#getPassword()`