Add default binding for AccountManager

74 views
Skip to first unread message

Roberto Tyley

unread,
Oct 19, 2011, 5:14:32 PM10/19/11
to robo...@googlegroups.com

Michael Burton

unread,
Oct 20, 2011, 6:07:30 AM10/20/11
to robo...@googlegroups.com
Done, thanks for the contribution!  You can check it out in the latest snapshot.  I had to make a small change to only perform the binding on API level 5 or above.

Cheers,
--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To view this discussion on the web visit https://groups.google.com/d/msg/roboguice/-/HtoYEUN9KDQJ.
To post to this group, send email to robo...@googlegroups.com.
To unsubscribe from this group, send email to roboguice+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/roboguice?hl=en.

Roberto Tyley

unread,
Oct 20, 2011, 9:59:01 AM10/20/11
to robo...@googlegroups.com
Cheers. thanks Michael!

Siarhei Dudzin

unread,
Oct 21, 2011, 5:26:55 AM10/21/11
to roboguice
Good stuff. Just needed this!

Siarhei

On Oct 20, 12:07 pm, Michael Burton <m...@niskala.org> wrote:
> Done, thanks for the contribution!  You can check it out in the latest snapshot.  I had to make a small change to only perform the binding on API level 5 or above.
>
> Cheers,
> Mike
>
> --http://about.me/michaelburton
>
> On Oct 19, 2011, at 11:14 PM, Roberto Tyley wrote:
>
>
>
>
>
>
>
>
>
> > Hi there, hope you can accept this patch which adds a default binding for android.accounts.AccountManager:
>
> >https://code.google.com/r/robertotyley-roboguice/source/detail?r=8d37...
>
> >http://developer.android.com/reference/android/accounts/AccountManage...
>
> > cheers,
> > Roberto
>
> > --
> > You received this message because you are subscribed to the Google Groups "roboguice" group.
> > To view this discussion on the web visithttps://groups.google.com/d/msg/roboguice/-/HtoYEUN9KDQJ.

Cherry Development

unread,
Dec 1, 2011, 8:00:06 PM12/1/11
to roboguice
Oops. So, if you ever want to do late binding when a class may or may
not be available based on an API version, you can NEVER refer to that
class as <class>.class, even if you wrap it in an 'if' statement.
Right now, any time the DefaultRoboModule class is loaded, it will
crash on SDK<5 because you're directly referring to
AccountManager.class. Similarly, it will crash if the fragment
manager compatibility is not included because you directly reference
FragementManager.class. You can't even refer directly to
FragmentManagereProvider.class and AccountManagerProvider.class
because loading those classes will cause the FragmentManager and
AccountManager classes to be loaded. You have to refer to all of
these classes with Class.forName. I'll log a bug report.

On Oct 20, 2:07 am, Michael Burton <m...@niskala.org> wrote:
> Done, thanks for the contribution!  You can check it out in the latest snapshot.  I had to make a small change to only perform the binding on API level 5 or above.
>
> Cheers,
> Mike
>

> --http://about.me/michaelburton


>
> On Oct 19, 2011, at 11:14 PM, Roberto Tyley wrote:
>
>
>
>
>
>
>
>
>
> > Hi there, hope you can accept this patch which adds a default binding for android.accounts.AccountManager:
>

> >https://code.google.com/r/robertotyley-roboguice/source/detail?r=8d37...
>
> >http://developer.android.com/reference/android/accounts/AccountManage...


>
> > cheers,
> > Roberto
>
> > --
> > You received this message because you are subscribed to the Google Groups "roboguice" group.

> > To view this discussion on the web visithttps://groups.google.com/d/msg/roboguice/-/HtoYEUN9KDQJ.

Roberto Tyley

unread,
Dec 2, 2011, 6:06:32 AM12/2/11
to robo...@googlegroups.com
On Friday, December 2, 2011 1:00:06 AM UTC, Cherry Development wrote:
Oops.  So, if you ever want to do late binding when a class may or may
not be available based on an API version, you can NEVER refer to that
class as <class>.class, even if you wrap it in an 'if' statement.
Right now, any time the DefaultRoboModule class is loaded, it will
crash on SDK<5 because you're directly referring to
AccountManager.class.

I think this eager classloading behaviour might be specific to Android 1.6 (api level 4) - quoting from Jake Wharton's recent blog post on ActionBarSherlock:

"Android’s 1.6 classloader is an over-eager know-it-all. It seeks out and checks every method call present in your loaded (key word!) classes. This means that even if you’ve blocked out a section in a check against Build.VERSION.SDK_INT, Android 1.6 will check every method inside."

Jake announces in the same blog post he's dropping support for Android 1.6 :-) To be honest, I'm not sure what the supported API level for RoboGuice is - there was some discussion in March 2011 that suggested the minimum functional Android version was 1.6:


As you probably know, Android 1.6 currently accounts for about 1% of the Android Market - though obviously there will be a higher percentage in niche markets - so personally my vote would be that as RoboGuice hits 2.0 it would be a good time to drop support for Android 1.6...!

best regards,
Roberto





 
Similarly, it will crash if the fragment
manager compatibility is not included because you directly reference
FragementManager.class.  You can't even refer directly to
FragmentManagereProvider.class and AccountManagerProvider.class
because loading those classes will cause the FragmentManager and
AccountManager classes to be loaded.  You have to refer to all of
these classes with Class.forName.  I'll log a bug report.
Reply all
Reply to author
Forward
0 new messages