Posts

Showing posts with the label Account

ActionBarCompat and NavigationDrawer

Image
In previous posts I talked about new ActionBarCompat . ActionBarSherlock vs ActionBarCompat How to add ActionBarCompat to your project In this post we'll try to use ActionBarCompat with the NavigationDrawer . If you have already implemented a NavigationDrawer with ActionBar, it is very easy to migrate to ActionBarCompat. I will use code I wrote with post Creating a Navigation Drawer . Here you can see steps: First of all you have to add ActionBarCompat to your project. Then: In your Activity you have to extend ActionBarActivity . Change getActionBar() with get getSupportActionBar() . Pay attention with invalidateOptionsMenu() . You have to change it with supportInvalidateOptionsMenu(); It is very easy! Some last tips: Be careful not to use attributes that work only with API 14+ , like ?android:attr/listPreferredItemHeightSmall or ?android:attr/textAppearanceListItemSmall . In this case you can use different styles using folder values-v14. Be careful w...

Snippet: Google Picker Account

Image
If we want to show a picker with Google accounts, it has become extremely simple with Google Play Services. Until a few months ago, we would have had to use something like this: AccountManager manager = (AccountManager) getSystemService(ACCOUNT_SERVICE); Account[] list = manager.getAccounts(); for(Account account: list) { if(account.type.equalsIgnoreCase("com.google")) { //Do something } } To use this code we need the following permission in your manifest: Now we can use new AccountPicker.newChooseAccountIntent() method. First of all, we need to make sure the Google Play Services client library is being included in the Android's project build path. Select Project > Properties > Java Build Path > Libraries from the Eclipse menu. Click Add External JARs. Browse to android-sdk-folder/extras/google/google_play_services/libproject/google-play-services_lib/libs, select google-play-services.jar and click OK. In the Order and Ex...