Fixed a crash that could occur if gtasks encounter auth problems during a background sync

pull/14/head
Sam Bosley 13 years ago
parent 07e493cedf
commit d536cdbf1e

@ -5,6 +5,7 @@ import java.io.IOException;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountManagerFuture;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@ -85,7 +86,10 @@ public class GtasksTokenValidator {
token = result.getString(AccountManager.KEY_AUTHTOKEN);
} else if (result.containsKey(AccountManager.KEY_INTENT)) {
Intent intent = (Intent) result.get(AccountManager.KEY_INTENT);
c.startActivity(intent);
if (c instanceof Activity)
c.startActivity(intent);
else
throw new GoogleTasksException(c.getString(R.string.gtasks_error_background_sync_auth));
return TOKEN_INTENT_RECEIVED;
} else {
throw new GoogleTasksException(c.getString(R.string.gtasks_error_accountManager));

@ -101,6 +101,8 @@
<!-- Error when account manager returns no auth token or throws exception -->
<string name="gtasks_error_accountManager">Error in your phone\'s account manager. Please log out and log back in from the Google Tasks settings.</string>
<!-- Error when authorization error happens in background sync -->
<string name="gtasks_error_background_sync_auth">Error authenticating in background. Please try initiating a sync while Astrid is running.</string>
</resources>

Loading…
Cancel
Save