Skip to content

Most visited

Recently visited

navigation

RecoverableSecurityException

public final class RecoverableSecurityException
extends SecurityException implements Parcelable

java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.lang.RuntimeException
         ↳ java.lang.SecurityException
           ↳ android.app.RecoverableSecurityException


Specialization of SecurityException that contains additional information about how to involve the end user to recover from the exception.

This exception is only appropriate where there is a concrete action the user can take to recover and make forward progress, such as confirming or entering authentication credentials.

Note: legacy code that receives this exception may treat it as a general SecurityException, and thus there is no guarantee that the messages contained will be shown to the end user.

Summary

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<RecoverableSecurityException> CREATOR

Public constructors

RecoverableSecurityException(Throwable cause, CharSequence userMessage, RemoteAction userAction)

Create an instance ready to be thrown.

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

RemoteAction getUserAction()

Return primary action that will initiate the recovery.

CharSequence getUserMessage()

Return short message describing the issue for end user audiences, which may be shown in a notification or dialog.

void showAsDialog(Activity activity)

Convenience method that will show a very simple dialog populated with the details from this exception.

void showAsNotification(Context context)

Convenience method that will show a very simple notification populated with the details from this exception.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

From class java.lang.Throwable
From class java.lang.Object
From interface android.os.Parcelable

Fields

Public constructors

RecoverableSecurityException

RecoverableSecurityException (Throwable cause, 
                CharSequence userMessage, 
                RemoteAction userAction)

Create an instance ready to be thrown.

Parameters
cause Throwable: original cause with details designed for engineering audiences.
userMessage CharSequence: short message describing the issue for end user audiences, which may be shown in a notification or dialog. This should be localized and less than 64 characters. For example: PIN required to access Document.pdf
userAction RemoteAction: primary action that will initiate the recovery. The title should be localized and less than 24 characters. For example: Enter PIN. This action must launch an activity that is expected to set setResult(int) before finishing to communicate the final status of the recovery. For example, apps that observe RESULT_OK may choose to immediately retry their operation.

Public methods

describeContents

int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

getUserAction

RemoteAction getUserAction ()

Return primary action that will initiate the recovery.

Returns
RemoteAction

getUserMessage

CharSequence getUserMessage ()

Return short message describing the issue for end user audiences, which may be shown in a notification or dialog.

Returns
CharSequence

showAsDialog

void showAsDialog (Activity activity)

Convenience method that will show a very simple dialog populated with the details from this exception.

If you want more flexibility over retrying your original operation once the user action has finished, consider presenting your own UI that uses startIntentSenderForResult(IntentSender, int, Intent, int, int, int) to launch the getIntentSender() from getUserAction() when requested. If the result of that activity is RESULT_OK, you should consider retrying.

This method will only display the most recent exception from any single remote UID; dialogs from older exceptions will always be replaced.

Parameters
activity Activity

showAsNotification

void showAsNotification (Context context)

Convenience method that will show a very simple notification populated with the details from this exception.

If you want more flexibility over retrying your original operation once the user action has finished, consider presenting your own UI that uses startIntentSenderForResult(IntentSender, int, Intent, int, int, int) to launch the getIntentSender() from getUserAction() when requested. If the result of that activity is RESULT_OK, you should consider retrying.

This method will only display the most recent exception from any single remote UID; notifications from older exceptions will always be replaced.

Parameters
context Context

writeToParcel

void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.