Integrating Google photo to Android application


Picasa – Google photo is a fast and easy sharing photo from Google. We can access Google photo album by integrating Android application.

Our steps:

  • Ask user to pick a google account
  • When we get the account back, ask for access to the picasa picture
  • Then we get our token
  • Get albums and images from picasa by our token

How to integrating

  1. Adding libraries by gradle
    compile ''
    compile group: '', name: 'core', version: '1.47.1'
  2. Ask user to pick a google account
    Intent googlePicker = AccountPicker.newChooseAccountIntent(null, null, new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE}, true, null, null, null, null);
    super.startActivityForResult(googlePicker, Config.PICK_PICASA_ALBUM);
  3. Get token
    public void onActivityResult(int requestCode, int result, Intent data) {
        if (result == RESULT_OK && requestCode == Config.PICK_PICASA_ALBUM) {
            super.onActivityResult(requestCode, result, data);
   = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
            this.type = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
    private void getTokenOfPicasa() {
        Account account = new Account(, this.type);
        AccountManager accountManager = AccountManager.get(this);
        accountManager.getAuthToken(account, "lh2", null, this,
            new AccountManagerCallback<Bundle>() {
                public void run(AccountManagerFuture<Bundle> result) {
                    try {
                        Bundle bundle = result.getResult();
                        if (bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
                            authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
                            new GetAlbumsOfPicasa().execute();
                    } catch (Exception e) {
                            Log.e(TAG, "getTokenOfPicasa", e);
        }, null);
  4. Get albums and images
    private class GetAlbumsOfPicasa extends AsyncTask<Void, Void, Void> {
        private List<Album> albums;
        protected Void doInBackground(Void... params) {
            // Get albums and images of Picasa
            getAlbumsOfPicasa(email, authToken);
            return null;
        protected void onPostExecute(Void aVoid) {
    public List<AlbumEntry> getAlbumsOfPicasa(String email, String authToken) {
        try {
            String API_PREFIX = "";
            PicasawebService picasaService = new PicasawebService("pictureframe");
            String albumUrl = API_PREFIX + email;
            UserFeed userFeed = picasaService.getFeed(new URL(albumUrl), UserFeed.class);
            List<GphotoEntry> entries = userFeed.getEntries();
            List<AlbumEntry> albums = new ArrayList<>();
            for (GphotoEntry entry : entries) {
                AlbumEntry albumEntry = new AlbumEntry(entry);
            return albums;
        } catch (Exception e) {
            Log.e(TAG, "getAlbumsOfPicasa", e);
            return null;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s