diff options
author | Robin Lee <rgl@google.com> | 2016-08-23 16:09:41 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-08-23 16:09:41 +0000 |
commit | c378aabddad75b0c3a2e18afe0c8a649e864dc93 (patch) | |
tree | 89e9d6bc48e04dd47d866a9c89e4b0b732a62e18 /keystore/java/android/security/KeyChain.java | |
parent | 2f6eecbed00c9bd91ead475626bebb089355e37e (diff) | |
parent | da23618043667e9cee680688b7413f65b400516e (diff) |
Documentation warning against short-lived Contexts
am: da23618043
Change-Id: Ie6e4c05d8d9a273f0f529c2be79f3df4a856fedb
Diffstat (limited to 'keystore/java/android/security/KeyChain.java')
-rw-r--r-- | keystore/java/android/security/KeyChain.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java index 30e5a2edd882..a96ca3922296 100644 --- a/keystore/java/android/security/KeyChain.java +++ b/keystore/java/android/security/KeyChain.java @@ -20,6 +20,7 @@ import android.annotation.Nullable; import android.annotation.WorkerThread; import android.app.Activity; import android.app.PendingIntent; +import android.app.Service; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -356,6 +357,9 @@ public final class KeyChain { * * <p> This method may block while waiting for a connection to another process, and must never * be called from the main thread. + * <p> As {@link Activity} and {@link Service} contexts are short-lived and can be destroyed + * at any time from the main thread, it is safer to rely on a long-lived context such as one + * returned from {@link Context#getApplicationContext()}. * * @param alias The alias of the desired private key, typically returned via * {@link KeyChainAliasCallback#alias}. @@ -400,6 +404,9 @@ public final class KeyChain { * * <p> This method may block while waiting for a connection to another process, and must never * be called from the main thread. + * <p> As {@link Activity} and {@link Service} contexts are short-lived and can be destroyed + * at any time from the main thread, it is safer to rely on a long-lived context such as one + * returned from {@link Context#getApplicationContext()}. * * @param alias The alias of the desired certificate chain, typically * returned via {@link KeyChainAliasCallback#alias}. |