public interface AccountManagerFuture 
 
| android.accounts.AccountManagerFuture<V> | 
甲AccountManagerFuture表示异步的结果AccountManager呼叫。 提供的方法用于检查计算是否完成,是否等待完成以及检索计算结果。 只有在计算完成时才能使用方法get来检索结果,如果有必要将其阻塞直到准备就绪。 取消由cancel方法执行。 提供了其他方法来确定任务是否正常完成或取消。 一旦计算完成,计算就不能被取消。 如果您希望为了取消而使用Future但未提供可用结果,则可以声明表单Future<?>的类型并返回null作为基础任务的结果。
公共方法(Public methods) |  
      |
|---|---|
 abstract boolean  |  
         cancel(boolean mayInterruptIfRunning)  试图取消执行此任务。  |  
      
 abstract V  |  
         getResult()  
  |  
      
 abstract V  |  
         getResult(long timeout, TimeUnit unit)  
  |  
      
 abstract boolean  |  
         isCancelled()  如果此任务在正常完成之前取消,则返回 true 。  |  
      
 abstract boolean  |  
         isDone()  如果此任务完成,则返回 true 。  |  
      
boolean cancel (boolean mayInterruptIfRunning)
试图取消执行此任务。 如果任务已完成,已被取消或因其他原因无法取消,此尝试将失败。 如果成功,并且此任务在调用cancel时尚未开始,则此任务不应运行。 如果任务已经启动,那么mayInterruptIfRunning参数确定执行此任务的线程是否应该中断以试图停止任务。
在此方法返回后,对isDone()后续调用将始终返回true 。 对后续调用isCancelled()总是返回true如果此方法返回true。
| 参数(Parameters) | |
|---|---|
mayInterruptIfRunning |  
         boolean: true if the thread executing this task should be interrupted; otherwise, in-progress tasks are allowed to complete |  
       
| 返回(Returns) | |
|---|---|
boolean |  
        false if the task could not be cancelled, typically because it has already completed normally; true otherwise | 
V getResult ()
AccountManagerFuture表示未来结果的AccountManagerFuture 。 此通话将阻止,直到结果可用。 为了检查结果是否可用而没有阻塞,可以调用isDone()和isCancelled() 。 如果生成此结果的请求失败或被取消,则会抛出异常而不是正常返回。
| 返回(Returns) | |
|---|---|
V |  
        the actual result | 
| 抛出异常(Throws) | |
|---|---|
OperationCanceledException |  
        if the request was canceled for any reason (including if it is forbidden by policy to modify an account (of that type)) | 
AuthenticatorException |  
        if there was an error communicating with the authenticator or if the authenticator returned an invalid response | 
IOException |  
        if the authenticator returned an error response that indicates that it encountered an IOException while communicating with the authentication server | 
V getResult (long timeout, 
                TimeUnit unit) 
     Accessor为未来结果AccountManagerFuture代表。 此通话将阻止,直到结果可用。 为了检查结果是否可用而没有阻塞,可以调用isDone()和isCancelled() 。 如果生成此结果的请求失败或被取消,则会抛出异常而不是正常返回。 如果指定了超时,那么如果该请求在该时间段内未完成,则该请求将被自动取消。
| 参数(Parameters) | |
|---|---|
timeout |  
         long: the maximum time to wait |  
       
unit |  
         TimeUnit: the time unit of the timeout argument. This must not be null. |  
       
| 返回(Returns) | |
|---|---|
V |  
        the actual result | 
| 抛出异常(Throws) | |
|---|---|
OperationCanceledException |  
        if the request was canceled for any reason | 
AuthenticatorException |  
        if there was an error communicating with the authenticator or if the authenticator returned an invalid response | 
IOException |  
        if the authenticator returned an error response that indicates that it encountered an IOException while communicating with the authentication server | 
boolean isCancelled ()
如果此任务在正常完成之前取消,则返回 true 。
| 返回(Returns) | |
|---|---|
boolean |  
        true if this task was cancelled before it completed | 
boolean isDone ()
如果此任务完成,则返回true 。 完成可能是由于正常终止,例外或取消 - 在所有这些情况下,此方法将返回true 。
| 返回(Returns) | |
|---|---|
boolean |  
        true if this task completed |