Question

I've implemented a custom AccountManager along the lines of Github Gauges or Github Android Client

More specifically, I'm implementing:

  • AccountAuthenticatorService (like here)
  • AccountAuthenticator (like here)
  • ApiKeyProvider which calls accountManagerFuture.getResult()

When accountManagerFuture.getResult() is called, my LoginActivity is started like should be. However, when the back button is pressed, I'm not getting an OperationException as should be (on the GitHub Gauges project it seems like it's working)

Anyone has an idea how to start debugging this?

Was it helpful?

Solution

What do you mean "when accountManagerFuture.getResult() is called"? Do you maintain a reference to the future after the back button is pressed and then call getResult() at some point afterwards? Because an OperationCanceledException will only be called if you explicitly call this method after the operation has been canceled.

Understanding the flow of events is a good place to start debugging the problem. When you press the back button onBackPressed() is called; onBackPressed() will then call finish(), and according to the source code for the AccountAuthenticatorActivity class, the overriden finish() method will send the signal that eventually cancels the task. Does that help you get started?

Also note that when you press the back button the operation will only be cancelled if the operation is still running. If the operation has already completed then no exception will be thrown (since there isn't any currently active operation for the framework to cancel). In other words, you might not get an exception when you press the back button... it all depends on whether the operation has already completed or not.

If you are still having trouble I would consider adding some code to your original question because otherwise it will be difficult for us to help you out any further. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top