From d536cdbf1e3239cfa4f01d6001640ec2bf4ea87d Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Wed, 28 Mar 2012 16:20:12 -0700 Subject: [PATCH] Fixed a crash that could occur if gtasks encounter auth problems during a background sync --- .../todoroo/astrid/gtasks/auth/GtasksTokenValidator.java | 6 +++++- astrid/res/values/strings-gtasks.xml | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksTokenValidator.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksTokenValidator.java index c48e64161..6f72bcc27 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksTokenValidator.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/auth/GtasksTokenValidator.java @@ -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)); diff --git a/astrid/res/values/strings-gtasks.xml b/astrid/res/values/strings-gtasks.xml index 2d4db8d20..9c3c3f65d 100644 --- a/astrid/res/values/strings-gtasks.xml +++ b/astrid/res/values/strings-gtasks.xml @@ -101,6 +101,8 @@ Error in your phone\'s account manager. Please log out and log back in from the Google Tasks settings. + + Error authenticating in background. Please try initiating a sync while Astrid is running.