[android-developers] Re: Google Play Services: UserRecoverableAuthException's intent doesn't start

2013-05-09 Thread b0b


On Monday, 11 March 2013 09:05:48 UTC+1, Goddchen wrote:
>
> I'm having issues with the Google Drive SDK for Android.
>
> Everything works fine except for some devices (on which it used to be 
> working, but now doesn't) the Intent that is returned by 
> `UserRecoverableAuthException.getIntent()` isn't doing anything when 
> started via `startIntent(...)`.
>
> All I see on Logcat is:
>
> 03-11 08:31:19.692: INFO/ActivityManager(552): START u0 {cat=[scope:oauth2:
>> https://www.googleapis.com/auth/drive,account:myem...@googlemail.com,extrashash:1088740320]
>>  
>> flg=0x1004 cmp=com.google.android.gms/.auth.TokenActivity (has extras)} 
>> from pid 27644
>
>
> That's it. Nothing happens on the device.
>
> This is how the Intent is launched:
>
> Intent intent = e.getIntent();
>> 
>> intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).addFlags(Intent.FLAG_FROM_BACKGROUND);
>> startActivity(intent);
>
>
> Any ideas?
>


This is probably because Google  Play Service handling this intent is not 
installed or not up to date. 
This can happen and here's how to handle it : 
http://developer.android.com/google/play-services/setup.html

To sum up, you must call 
GooglePlayServiceUtils.isGooglePlayServicesAvailable() and handle it if it 
returns something else than 
SUCCESS
.


-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Google Play Services: UserRecoverableAuthException's intent doesn't start

2013-05-09 Thread Goddchen
In my sepcific case, the problem was that I was launching the intent from a
Service. But a Service doesn't have a onActivityResult(...) callback.
So I found that there are some requirements for the startActivity(Intent)
call
1) It's not startActivity, but it HAS TO be startActivityForResult(...)
which can of course only be launched from Activities

Hope this helps you. And it would really be helpful to receive any logcat
output indicating this issue instead of just doing/loggin nothing at all :(

Goddchen


--
Martin "Goddchen" Liersch
> Blog: http://blog.goddchen.de
> Website: http://www.goddchen.de


2013/5/8 Ryan Harter 

> Did you ever find a resolution for this?  I'm seeing the same behavior in
> the dredit sample Drive SDK code, and my code based off of it.  I create a
> pending intent out of the intent returned from getIntent(), but it doesn't
> launch.
>
> Here is my code, taken directly from the sample:
>
> try {
> GoogleAccountCredential credential =
> GoogleAccountCredential.usingOAuth2(mContext, DriveScopes.DRIVE_FILE);
>  credential.setSelectedAccountName(mAccount.name);
> // Trying to get a token right away to see if we are authorized
>  credential.getToken();
> mService = new Drive.Builder(AndroidHttp.newCompatibleTransport(),
> new GsonFactory(), credential).build();
> } catch (UserRecoverableAuthException e) {
> Log.e("Failed to get token");
> // If the exception is User Recoverable, we display a notification that
> will trigger the
>  // intent to fix the issue.
> Log.e("Notifying with intent: " + e.getIntent().toString());
> NotificationManager notificationManager = (NotificationManager) mContext
>  .getSystemService(Context.NOTIFICATION_SERVICE);
> Intent authorizationIntent = e.getIntent();
> authorizationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).addFlags(
>  Intent.FLAG_FROM_BACKGROUND);
> PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0,
> authorizationIntent, 0);
>  Notification notification = new Notification.Builder(mContext)
> .setSmallIcon(android.R.drawable.ic_dialog_alert)
>  .setTicker("Permission requested")
> .setContentTitle("Permission requested")
> .setContentText("for account " + mAccount.name)
>  .setContentIntent(pendingIntent).setAutoCancel(true).build();
> notificationManager.notify(0, notification);
> } catch (Exception e) {
>  e.printStackTrace();
> }
>
> On Monday, March 11, 2013 3:05:48 AM UTC-5, Goddchen wrote:
>>
>> I'm having issues with the Google Drive SDK for Android.
>>
>> Everything works fine except for some devices (on which it used to be
>> working, but now doesn't) the Intent that is returned by
>> `UserRecoverableAuthException.**getIntent()` isn't doing anything when
>> started via `startIntent(...)`.
>>
>> All I see on Logcat is:
>>
>> 03-11 08:31:19.692: INFO/ActivityManager(552): START u0
>>> {cat=[scope:oauth2:https://**www.googleapis.com/auth/drive,**
>>> account:myemail@googlemail.**com,extrashash:1088740320]
>>> flg=0x1004 cmp=com.google.android.gms/.**auth.TokenActivity (has
>>> extras)} from pid 27644
>>
>>
>> That's it. Nothing happens on the device.
>>
>> This is how the Intent is launched:
>>
>> Intent intent = e.getIntent();
>>> intent.addFlags(Intent.FLAG_**ACTIVITY_NEW_TASK).addFlags(**
>>> Intent.FLAG_FROM_BACKGROUND);
>>> startActivity(intent);
>>
>>
>> Any ideas?
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-developers/vbsRjxAPOuo/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, send an email to
> android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Google Play Services: UserRecoverableAuthException's intent doesn't start

2013-05-08 Thread Ryan Harter
Did you ever find a resolution for this?  I'm seeing the same behavior in 
the dredit sample Drive SDK code, and my code based off of it.  I create a 
pending intent out of the intent returned from getIntent(), but it doesn't 
launch.

Here is my code, taken directly from the sample:

try {
GoogleAccountCredential credential =
GoogleAccountCredential.usingOAuth2(mContext, DriveScopes.DRIVE_FILE);
credential.setSelectedAccountName(mAccount.name);
// Trying to get a token right away to see if we are authorized
credential.getToken();
mService = new Drive.Builder(AndroidHttp.newCompatibleTransport(),
new GsonFactory(), credential).build();
} catch (UserRecoverableAuthException e) {
Log.e("Failed to get token");
// If the exception is User Recoverable, we display a notification that 
will trigger the
// intent to fix the issue.
Log.e("Notifying with intent: " + e.getIntent().toString());
NotificationManager notificationManager = (NotificationManager) mContext
.getSystemService(Context.NOTIFICATION_SERVICE);
Intent authorizationIntent = e.getIntent();
authorizationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).addFlags(
Intent.FLAG_FROM_BACKGROUND);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, 
authorizationIntent, 0);
Notification notification = new Notification.Builder(mContext)
.setSmallIcon(android.R.drawable.ic_dialog_alert)
.setTicker("Permission requested")
.setContentTitle("Permission requested")
.setContentText("for account " + mAccount.name)
.setContentIntent(pendingIntent).setAutoCancel(true).build();
notificationManager.notify(0, notification);
} catch (Exception e) {
e.printStackTrace();
}

On Monday, March 11, 2013 3:05:48 AM UTC-5, Goddchen wrote:
>
> I'm having issues with the Google Drive SDK for Android.
>
> Everything works fine except for some devices (on which it used to be 
> working, but now doesn't) the Intent that is returned by 
> `UserRecoverableAuthException.getIntent()` isn't doing anything when 
> started via `startIntent(...)`.
>
> All I see on Logcat is:
>
> 03-11 08:31:19.692: INFO/ActivityManager(552): START u0 {cat=[scope:oauth2:
>> https://www.googleapis.com/auth/drive,account:myem...@googlemail.com,extrashash:1088740320]
>>  
>> flg=0x1004 cmp=com.google.android.gms/.auth.TokenActivity (has extras)} 
>> from pid 27644
>
>
> That's it. Nothing happens on the device.
>
> This is how the Intent is launched:
>
> Intent intent = e.getIntent();
>> 
>> intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).addFlags(Intent.FLAG_FROM_BACKGROUND);
>> startActivity(intent);
>
>
> Any ideas?
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.