Today I am going to show to how to build a free wallpapers app using Picasa Web Albums API. In this tutorial you can learn how to integrate multiple android components like splash screen, navigation drawer, grid view, volley library in a single app.

As this tutorial seems very lengthy, I divided this into two parts. In 1st part we do all basic setup like creating the Picasa albums, planning the app design and creating the android project and write some reusable components required for the app. In the 2nd part the actual implementation of the app starts where we add one by one module to the app like splash screen, navigation drawer, grid view and other things to complete the app.

android free wallpapers app part 2

1. Prerequisite

As this app is a complete application we need to integrate several components together. Please go through below articles before getting into this tutorial as these concepts are main building blocks for this app.

1. How to implement Android Splash Screen This explains how to add a splash screen to your app when the app needs to make few HTTP calls and fetch some data before going in to actual app flow.

2. Android Sliding Menu using Navigation Drawer This article helps in adding a slider menu for the app where we can show list of categories for wallpapers.

3. Android working with Volley Library We use volley to make network calls like downloading the json and images. Also another main advantage of using volley is image cache which makes the app faster.

4. Android Full Screen Image Slider with Swipe and Pinch Zoom Gestures This is another important article helps in creating the app’s main Grid View screen where the thumbnail preview of each wallpaper will be displayed in a grid fashion.

2. Google’s Picasa Web Albums API

The major and difficult task in this app is building the server side components like an admin panel to manage your wallpaper data by providing file upload option and other things. For this you should also able to code in other technologies like HTML, CSS, JSP, PHP or MySQL which is again a difficult task for android beginners.

So I selected Picasa Web Albums as a robust solution for this. Picasa web albums is free of cost and importantly it exposes an API (json and xml) for developers. You can go through Picasa Web Albums Data API to know more about the API’s exposed.

We are specifically interested in following API calls for this app which doesn’t require any authentication as we perform read operations only on public albums.

1. Request a list of albums
(username should be replaced with your Google username)

https://picasaweb.google.com/data/feed/api/user/username?kind=album&alt=json

2. List photos recently uploaded
(username should be replaced with your Google username)

https://picasaweb.google.com/data/feed/api/user/username?kind=photo&alt=json

3. List photos in album
(albumid should be replaced with actual album id which can find in albums response)

https://picasaweb.google.com/data/feed/api/user/username/albumid/albumid?alt=json

If you want to provide more options like providing user to comment, edit or delete options you need to implement authentication as mentioned in the document.

Hint: alt parameter decides the type of response we are expecting either json or xml. Pass alt=json in the url to get the response in JSON format.

3. Adding wallpapers in Picasa Web Albums

Before starting the app, we’ll add few wallpapers in Picasa albums for testing. You can login into Picasa using your Google account. Follow below steps to create albums and wallpapers in Picasa web albums.

1. Login into Picasa.
(If you are redirected to your Google+ account, click on Click here to go back to Picasa Web Albums to navigate back to Picasa Web or go with Google+ if you are comfortable)

2. Click on upload and enter your album name. These albums act as wallpaper categories in our app which will be listed in navigation drawer menu. Example: Animals, Cars, Food, Movies, Vintage etc.,

3. Once you created the album, upload few wallpapers to the album. Make sure that you are uploading the wallpapers with good high resolution.

4. Now make the album visibility as Public by clicking on Edit link displayed on the right. Note: If you don’t make your album as public, it will not be accessible via your android app. In other words you can’t see the album in the json response.

5. Follow 2nd, 3rd and 4th steps to create few more albums and wallpapers.

Checkout the below video which takes you through uploading process.


4. Designing The App

The design of this app is very minimalistic with very few color combinations. Overall it contains following components.

1. Navigation drawer (Slider Menu) to display wallpaper categories.
2. Grid view screen to display the thumbnail of wallpapers under a category.
3. Full screen view of wallpaper with Set As Wallpaper and Download Wallpaper options.
4. Settings screen to configure Picasa username, number of columns in grid and gallery image directory.

Below are screen shots of the final app.

Splash Screen

android freewallpapers app splash screen

Navigation Drawer

android wallpapers navigation drawer

Wallpapers thumbnail view

android wallpapers app grid view

Full screen view with Set As Wallpaper and Download options

android wallpapers app fullscreen view

Settings view

android wallpapers settings screen

5. Downloading Volley Library (volley.jar)

To make calls to Picasa API we are going to use Volley Library instead of using the java library mentioned in the documentation. I already published an article about Volley Library explaining about the advantages of choosing volley. In this project it plays a major role in caching the images.

Download the precompiled volley.jar

Now it’s time to start the android app. I am naming this app as Awesome Wallpapers.

6. Creating New Project

1. In Eclipse create a new project by navigating to File ⇒ New ⇒ Android Application Project and fill required details. I gave my project package name as info.androidhive.awesomewallpapers

2. Once the project is created paste the volley.jar in libs folder.

3. Download the resources and place them in your project’s respective folders. In this downloaded zip you will find splash screen background image and other app icons.

4. Now add below resource values in strings.xml, colors.xml. These values are used in various places in the project.

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Awesome Wallpapers</string>
    <string name="action_settings">Settings</string>
    <string name="nav_drawer_recently_added">Recently Added</string>
    <string name="toast_saved">Wallpapaer saved to #</string>
    <string name="toast_saved_failed">Sorry! Failed to save wallpaper</string>
    <string name="toast_wallpaper_set">Wallpapaer updated!</string>
    <string name="toast_wallpaper_set_failed">Sorry! Unable to set wallpapaer</string>
    <string name="splash_error">Unable to download wallpapers. Verify your google\'s user name in settings or device doesn\'t have internet connection!</string>
    <string name="set_wallpaper">Set</string>
    <string name="download_wallpaper">Download</string>
    <string name="msg_unknown_error">Sorry! Unknown error occurred.</string>
    <string name="msg_wall_fetch_error">Sorry! Unable to fetch wallpaper(s). Verify app settings or device doesn\'t have internet connection.</string>
    <string name="toast_enter_google_username">Please enter google username</string>
    <string name="toast_enter_valid_grid_columns">Please enter valid number of columns</string>
    <string name="toast_enter_gallery_name">Please enter gallery directory name</string>
    <string name="lbl_google_username">Google username</string>
    <string name="lbl_no_grid_columns">Number of grid columns</string>
    <string name="lbl_gallery_name">Gallery directory name</string>
    <string name="lbl_btn_save">Save</string>

</resources>

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <color name="list_item_title">#d7ddee</color>
    <color name="list_background">#1a1b1d</color>
    <color name="list_background_pressed">#131315</color>
    <color name="list_divider">#272727</color>
    <color name="counter_text_bg">#626262</color>
    <color name="counter_text_color">#c5c4c4</color>
    <color name="black">#000000</color>
    <color name="grid_bg">#000000</color>
    <color name="grid_item_bg">#1a1b1d</color>
    <color name="action_bar">#141416</color>
    <color name="action_bar_title">#ffffff</color>
    <color name="white">#ffffff</color>
    <color name="settings_label">#323232</color>

</resources>

5. Now create five packages named app, helper, util and picasa.model under src folder. Right Click on src ⇒ New ⇒ Package.

info.androidhive.awesomewallpapers.app
info.androidhive.awesomewallpapers.helper
info.androidhive.awesomewallpapers.picasa.model
info.androidhive.awesomewallpapers.util

6. Now create AppConst.java in app package. All the app configuration like google username, picasa api urls, gallery directory name and other static variables goes in this class.

package info.androidhive.awesomewallpapers.app;


public class AppConst {

	// Number of columns of Grid View
	// by default 2 but user can configure this in settings activity
	public static final int NUM_OF_COLUMNS = 2;

	// Gridview image padding
	public static final int GRID_PADDING = 4; // in dp

	// Gallery directory name to save wallpapers
	public static final String SDCARD_DIR_NAME = "Awesome Wallpapers";

	// Picasa/Google web album username
	public static final String PICASA_USER = "freewallpapersapp";

	// Public albums list url
	public static final String URL_PICASA_ALBUMS = "https://picasaweb.google.com/data/feed/api/user/_PICASA_USER_?kind=album&alt=json";

	// Picasa album photos url
	public static final String URL_ALBUM_PHOTOS = "https://picasaweb.google.com/data/feed/api/user/_PICASA_USER_/albumid/_ALBUM_ID_?alt=json";

	// Picasa recenlty added photos url
	public static final String URL_RECENTLY_ADDED = "https://picasaweb.google.com/data/feed/api/user/_PICASA_USER_?kind=photo&alt=json";

}

7. Create another class named AppController.java under app package. This class extends from Application and this is a singleton class which initializes volley’s core objects and few other classes those can be used across the app.

package info.androidhive.awesomewallpapers.app;

import info.androidhive.awesomewallpapers.util.LruBitmapCache;
import info.androidhive.awesomewallpapers.util.PrefManager;
import android.app.Application;
import android.text.TextUtils;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;

public class AppController extends Application {

	public static final String TAG = AppController.class.getSimpleName();

	private RequestQueue mRequestQueue;
	private ImageLoader mImageLoader;
	LruBitmapCache mLruBitmapCache;

	private static AppController mInstance;
	private PrefManager pref;

	@Override
	public void onCreate() {
		super.onCreate();
		mInstance = this;
		pref = new PrefManager(this);
	}

	public static synchronized AppController getInstance() {
		return mInstance;
	}

	public PrefManager getPrefManger() {
		if (pref == null) {
			pref = new PrefManager(this);
		}

		return pref;
	}

	public RequestQueue getRequestQueue() {
		if (mRequestQueue == null) {
			mRequestQueue = Volley.newRequestQueue(getApplicationContext());
		}

		return mRequestQueue;
	}

	public ImageLoader getImageLoader() {
		getRequestQueue();
		if (mImageLoader == null) {
			getLruBitmapCache();
			mImageLoader = new ImageLoader(this.mRequestQueue, mLruBitmapCache);
		}

		return this.mImageLoader;
	}

	public LruBitmapCache getLruBitmapCache() {
		if (mLruBitmapCache == null)
			mLruBitmapCache = new LruBitmapCache();
		return this.mLruBitmapCache;
	}

	public <T> void addToRequestQueue(Request<T> req, String tag) {
		req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
		getRequestQueue().add(req);
	}

	public <T> void addToRequestQueue(Request<T> req) {
		req.setTag(TAG);
		getRequestQueue().add(req);
	}

	public void cancelPendingRequests(Object tag) {
		if (mRequestQueue != null) {
			mRequestQueue.cancelAll(tag);
		}
	}
}

8. Create Utils.java under util package. This class contains few helper methods.

package info.androidhive.awesomewallpapers.util;

import info.androidhive.awesomewallpapers.R;

import java.io.File;
import java.io.FileOutputStream;
import java.util.Random;

import android.app.WallpaperManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.os.Environment;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import android.widget.Toast;

public class Utils {
	private String TAG = Utils.class.getSimpleName();
	private Context _context;
	private PrefManager pref;

	// constructor
	public Utils(Context context) {
		this._context = context;
		pref = new PrefManager(_context);
	}

	/*
	 * getting screen width
	 */
	@SuppressWarnings("deprecation")
	public int getScreenWidth() {
		int columnWidth;
		WindowManager wm = (WindowManager) _context
				.getSystemService(Context.WINDOW_SERVICE);
		Display display = wm.getDefaultDisplay();

		final Point point = new Point();
		try {
			display.getSize(point);
		} catch (java.lang.NoSuchMethodError ignore) {
			// Older device
			point.x = display.getWidth();
			point.y = display.getHeight();
		}
		columnWidth = point.x;
		return columnWidth;
	}

	public void saveImageToSDCard(Bitmap bitmap) {
		File myDir = new File(
				Environment
						.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
				pref.getGalleryName());

		myDir.mkdirs();
		Random generator = new Random();
		int n = 10000;
		n = generator.nextInt(n);
		String fname = "Wallpaper-" + n + ".jpg";
		File file = new File(myDir, fname);
		if (file.exists())
			file.delete();
		try {
			FileOutputStream out = new FileOutputStream(file);
			bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
			out.flush();
			out.close();
			Toast.makeText(
					_context,
					_context.getString(R.string.toast_saved).replace("#",
							"\"" + pref.getGalleryName() + "\""),
					Toast.LENGTH_SHORT).show();
			Log.d(TAG, "Wallpaper saved to: " + file.getAbsolutePath());

		} catch (Exception e) {
			e.printStackTrace();
			Toast.makeText(_context,
					_context.getString(R.string.toast_saved_failed),
					Toast.LENGTH_SHORT).show();
		}
	}

	public void setAsWallpaper(Bitmap bitmap) {
		try {
			WallpaperManager wm = WallpaperManager.getInstance(_context);

			wm.setBitmap(bitmap);
			Toast.makeText(_context,
					_context.getString(R.string.toast_wallpaper_set),
					Toast.LENGTH_SHORT).show();
		} catch (Exception e) {
			e.printStackTrace();
			Toast.makeText(_context,
					_context.getString(R.string.toast_wallpaper_set_failed),
					Toast.LENGTH_SHORT).show();
		}
	}
}

9. Create LruBitmapCache.java and paste the below code. This class used to keep the volley cached objects on the disk.

package info.androidhive.awesomewallpapers.util;

import com.android.volley.toolbox.ImageLoader.ImageCache;

import android.graphics.Bitmap;
import android.support.v4.util.LruCache;

public class LruBitmapCache extends LruCache<String, Bitmap> implements
		ImageCache {
	public static int getDefaultLruCacheSize() {
		final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
		final int cacheSize = maxMemory / 8;

		return cacheSize;
	}

	public LruBitmapCache() {
		this(getDefaultLruCacheSize());
	}

	public LruBitmapCache(int sizeInKiloBytes) {
		super(sizeInKiloBytes);
	}

	@Override
	protected int sizeOf(String key, Bitmap value) {
		return value.getRowBytes() * value.getHeight() / 1024;
	}

	@Override
	public Bitmap getBitmap(String url) {
		return get(url);
	}

	@Override
	public void putBitmap(String url, Bitmap bitmap) {
		put(url, bitmap);
	}
}

10. Create two classes named Category.java and Wallpaper.java under picasa.model package. These POJO classes will be useful while parsing the json data fetched from Picasa.

package info.androidhive.awesomewallpapers.picasa.model;

public class Category {
	public String id, title;

	public Category() {		
	}

	public Category(String id, String title) {		
		this.id = id;
		this.title = title;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
}
package info.androidhive.awesomewallpapers.picasa.model;

import java.io.Serializable;

public class Wallpaper implements Serializable {
	private static final long serialVersionUID = 1L;
	private String url, photoJson;
	private int width, height;

	public Wallpaper() {
	}

	public Wallpaper(String photoJson, String url, int width, int height) {		
		this.photoJson = photoJson;
		this.url = url;
		this.width = width;
		this.height = height;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getPhotoJson() {
		return photoJson;
	}

	public void setPhotoJson(String photoJson) {
		this.photoJson = photoJson;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}
}

11. Finally create another class named PrefManager.java under utils package. This class takes care of storing the data in Shared Preferences. The data like google username, picasa wallpaper categories, gallery name and other things will be stored in shared preferences.

package info.androidhive.awesomewallpapers.util;

import info.androidhive.awesomewallpapers.app.AppConst;
import info.androidhive.awesomewallpapers.picasa.model.Category;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;

import com.google.gson.Gson;

public class PrefManager {
	private static final String TAG = PrefManager.class.getSimpleName();

	// Shared Preferences
	SharedPreferences pref;

	// Editor for Shared preferences
	Editor editor;

	// Context
	Context _context;

	// Shared pref mode
	int PRIVATE_MODE = 0;

	// Sharedpref file name
	private static final String PREF_NAME = "AwesomeWallpapers";

	// Google's username
	private static final String KEY_GOOGLE_USERNAME = "google_username";

	// No of grid columns
	private static final String KEY_NO_OF_COLUMNS = "no_of_columns";

	// Gallery directory name
	private static final String KEY_GALLERY_NAME = "gallery_name";

	// gallery albums key
	private static final String KEY_ALBUMS = "albums";

	public PrefManager(Context context) {
		this._context = context;
		pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);

	}

	/**
	 * Storing google username
	 * */
	public void setGoogleUsername(String googleUsername) {
		editor = pref.edit();

		editor.putString(KEY_GOOGLE_USERNAME, googleUsername);

		// commit changes
		editor.commit();
	}

	public String getGoogleUserName() {
		return pref.getString(KEY_GOOGLE_USERNAME, AppConst.PICASA_USER);
	}

	/**
	 * store number of grid columns
	 * */
	public void setNoOfGridColumns(int columns) {
		editor = pref.edit();

		editor.putInt(KEY_NO_OF_COLUMNS, columns);

		// commit changes
		editor.commit();
	}

	public int getNoOfGridColumns() {
		return pref.getInt(KEY_NO_OF_COLUMNS, AppConst.NUM_OF_COLUMNS);
	}

	/**
	 * storing gallery name
	 * */
	public void setGalleryName(String galleryName) {
		editor = pref.edit();

		editor.putString(KEY_GALLERY_NAME, galleryName);

		// commit changes
		editor.commit();
	}

	public String getGalleryName() {
		return pref.getString(KEY_GALLERY_NAME, AppConst.SDCARD_DIR_NAME);
	}

	/**
	 * Storing albums in shared preferences
	 * */
	public void storeCategories(List<Category> albums) {
		editor = pref.edit();
		Gson gson = new Gson();

		Log.d(TAG, "Albums: " + gson.toJson(albums));

		editor.putString(KEY_ALBUMS, gson.toJson(albums));

		// save changes
		editor.commit();
	}

	/**
	 * Fetching albums from shared preferences. Albums will be sorted before
	 * returning in alphabetical order
	 * */
	public List<Category> getCategories() {
		List<Category> albums = new ArrayList<Category>();

		if (pref.contains(KEY_ALBUMS)) {
			String json = pref.getString(KEY_ALBUMS, null);
			Gson gson = new Gson();
			Category[] albumArry = gson.fromJson(json, Category[].class);

			albums = Arrays.asList(albumArry);
			albums = new ArrayList<Category>(albums);
		} else
			return null;

		List<Category> allAlbums = albums;

		// Sort the albums in alphabetical order
		Collections.sort(allAlbums, new Comparator<Category>() {
			public int compare(Category a1, Category a2) {
				return a1.getTitle().compareToIgnoreCase(a2.getTitle());
			}
		});

		return allAlbums;

	}

	/**
	 * Comparing albums titles for sorting
	 * */
	public class CustomComparator implements Comparator<Category> {
		@Override
		public int compare(Category c1, Category c2) {
			return c1.getTitle().compareTo(c2.getTitle());
		}
	}
}

Now we have all the required classes in place. So let’s start adding one by one component to the app in Android Building Free Wallpapers App – Part 2

Subscribe
Notify of
guest
135 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
sud007
6 years ago

Cool!
will try this!

عثمان السليماني المغرب
عثمان السليماني المغرب
6 years ago

or the best

kamran
kamran
6 years ago

yesss

Nilu Patel
6 years ago

Dear Ravi,

On Click Recently Added, Volley getting Error: Could not Delete cache entry for key=https://picasaweb.google.com/data/feed/api/user/nilay.scet?albumid/5637447830974140801?alt=json, filename=-1830143455-280059811

and also give same error in Profile Photos

AK
AK
6 years ago

Hi Ravi nice tutorial.. i have doubt. I saved the wall paper but I couldn’t find the saved picture in Gallery but it’s exist storage/pictures/awesome wallpapers. what may be the issue? Please solve the problem and update the code. Thanks in advance

WhiteOne
WhiteOne
5 years ago
Reply to  AK

hello, did you find a solution for this problem? thanks

Guest
Guest
6 years ago

error @ import com.google.gson.Gson;
in PrefManager

MackAttack
MackAttack
6 years ago
Reply to  Guest

you need to download the google gson library from google.

aniket
aniket
6 years ago

how to hide profile picture and scrapbook pictures ….as they are public by default…they are showed up in recently added category…. 🙁

Suat
Suat
6 years ago

best tuttorial. it works stable

Capkin
Capkin
5 years ago
Reply to  Suat

hi i have some problem can you help me?

sokea
sokea
6 years ago

thank for your tutorial .Can you make tutorial about How to play youtube in fragment ? using your Tutorial Menu using Navigation Drawer

Capkin
Capkin
5 years ago

error @ ActionBarDrawerToogle in MainActivity

chien
chien
5 years ago

thank for your tutorial…but it is low loading

Mardoqueu Sousa
Mardoqueu Sousa
5 years ago

I didn’t understand, I tried several times get my own wallpapers from picasa chaging PICASA_USER by the mine, could explain me what should I to do??? I just wanted get my own pictures from picasa…

Byron Viljoen
Byron Viljoen
5 years ago

Download links not working… seems to be timing out.

Khalil Serano
Khalil Serano
5 years ago

guys can anyone tell me how to change Package name without getting errors please

Hector Franco
Hector Franco
5 years ago
Reply to  Khalil Serano

If you are using Android Studio, you can go to “bulid.grade” file in your proyect and change the line
applicationid for your new package name, and it’s not necessary doing something else.

defaultConfig {

applicationId “com.studios.rev.tech.wallpapergallery”

minSdkVersion 14

targetSdkVersion 19

}

Mohammad
Mohammad
5 years ago

Hi Ravi,
How Can i get image with HTTP protocol? Because in same device in my country can’t view image 🙁
Please Help me!

Hector Franco
Hector Franco
5 years ago

Hi guys, i want to thank for this tutorial and this app, it’s incrediblely help to me, i have a little problem with Picasa, so, as you can see Picasa is assosiate with Google Plus, when i put my User of Google, it has a Album called Profile Picture, What can i do for the app ignore that album? Thank you guys

hanish yadav
hanish yadav
5 years ago
Reply to  Hector Franco

create a new account and do not activate g+ account

Ahmet Öney
Ahmet Öney
5 years ago

Hello. How do I add my own album with this application?

deni777
deni777
5 years ago

How to hide album “Profile Photos” ?

Urvish
Urvish
5 years ago
Reply to  deni777

same question.i need help

Ahmed Turk
Ahmed Turk
5 years ago
Reply to  Urvish

you can hide profile photos from this link of picasa https://picasaweb.google.com/home

Jinson K V
5 years ago
Reply to  deni777

Why don’t you delete the profile pictures? For my new project, I created a new account and deleted the profile pictures.. Not it is OK…

Sahitya Kumar Suman
Sahitya Kumar Suman
5 years ago

@Ravi Tamada

My app is opening again and again setting activity and saying that your google username is not

and shows

Volley Error: java.net.UnknownHostException: Unable to resolve host “picasaweb.google.com”: No address associated with hostname

following error

deni777
deni777
5 years ago

I have problem with quality of wallpapers.I upload wallpapers with size-2560×1600,but wallpapers looks with low quality.On picasa image is over 4 mb wen save same image on my device is over 2mb.

hacker don't have
hacker don't have
5 years ago

running in emulator but not installing in device……………. please help

deni777
deni777
5 years ago

Hope that will get help! I try app on emulator and get error-05-22 09:27:51.670: E/dalvikvm-heap(675): Out of memory on a 5753616-byte allocation.

05-22 09:27:51.770: E/Volley(675): [79] ImageRequest.parseNetworkResponse: Caught OOM for 737392 byte image, urlcomment image

deni777
deni777
5 years ago

What should be maximum wallpaper size in px and mb.I got error in emulator for low heap space.Please answer me!

66666666666
66666666666
5 years ago

5666666666666

romani.kandelaki
romani.kandelaki
5 years ago

Hi guys, please, how to edit downloaded files? I have just Android Studio – Can I to edit this project here? or I need some program?

Bijay Chamlagai
Bijay Chamlagai
5 years ago

How to add zoom in and out function and image opens in portrait only

Ranjan Mishra
Ranjan Mishra
5 years ago

Can you please update this tutorial with material design 🙂

Ravi Tamada
5 years ago
Reply to  Ranjan Mishra

It is already.

Nikhil Singh
Nikhil Singh
5 years ago
Reply to  Ravi Tamada

Sir , plz tell me how to change the color of status bar. I tried evrything but i failed.:/

sarun
sarun
5 years ago

sir i have a problem, saved folder & images not showing in gallery.but can view through file managers.how to update media scanner

thnxs for the nice tutorials

Ravi Tamada
5 years ago
Reply to  sarun

I have seen this problem. Its because gallery is not refreshing. All the images will be shown on device reboot. You need to refresh the gallery after saving the image.
http://stackoverflow.com/questions/4144840/how-can-i-refresh-the-gallery-after-i-inserted-an-image-in-android

sarun
sarun
5 years ago
Reply to  Ravi Tamada

Thank u sir

Ala'a Abdullah
Ala'a Abdullah
5 years ago

Adding this code i found on stackoverflow to the saveImage2Sd method did the job for the images that are not showing in the gallery.

private void scanMedia(File path) {

Uri uri = Uri.fromFile(path);
Intent scanFileIntent = new Intent(
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
_context.sendBroadcast(scanFileIntent);
}

Hope it helps.

sarun
sarun
5 years ago
Reply to  Ala'a Abdullah

thank u for the replay
It worked

Nikhil Singh
Nikhil Singh
5 years ago
Reply to  sarun

bro plz tell me where in saveimage2sd method should i paste this code. i m getting error while pasting it..:( plz help

sarun
sarun
5 years ago
Reply to  Nikhil Singh

Actually it won’t work on new devices 4.4 +

and media scanner method require more resources, it will slow down devices with more contents on storage

so i go with the mediastore db update approach

Try this

ContentValues values = new ContentValues();

values.put(MediaStore.Images.Media.DATA,file.getAbsolutePath());

values.put(MediaStore.Images.Media.MIME_TYPE,”image/jpeg”);

_context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,values);

happy coding 😉

Nikhil Singh
Nikhil Singh
5 years ago
Reply to  sarun

Thanx bro for the rply!
i worked like a charm..:) thanx a lot.
happy coding:)

Shirisha Gangula
Shirisha Gangula
5 years ago

While running my is crashed.i dont know what is the error

my AppConst.java is

public class AppConst {

// Number of columns of Grid View
// by default 2 but user can configure this in settings activity
public static final int NUM_OF_COLUMNS = 2;

// Gridview image padding
public static final int GRID_PADDING = 4; // in dp

// Gallery directory name to save wallpapers
public static final String SDCARD_DIR_NAME = “Awesome Wallpapers”;
// Picasa/Google web album username
public static final String PICASA_USER = “freewallpapersapp”;

// Public albums list url
public static final String URL_PICASA_ALBUMS = “https://picasaweb.google.com/data/feed/api/user/shirishasaikumar?kind=album&alt=json”;

// Picasa album photos url
public static final String URL_ALBUM_PHOTOS = “https://picasaweb.google.com/data/feed/api/user/shirishasaikumar/albumid/_ALBUM_ID_?alt=json”;

// Picasa recenlty added photos url
public static final String URL_RECENTLY_ADDED = “https://picasaweb.google.com/data/feed/api/user/shirishasaikumar?kind=photo&alt=json”;

}

when my app crashes im getting the following things in logcat

08-12 16:43:22.389 18251-18251/? W/dalvikvm﹕ VFY: unable to resolve virtual method 537: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;

08-12 16:43:22.459 18251-18251/? W/GAv4﹕ CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.

08-12 16:43:22.839 18312-18312/? I/MultiDex﹕ install

08-12 16:43:22.859 18312-18312/? I/MultiDex﹕ install done

08-12 16:43:23.149 18312-18347/? I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzh

08-12 16:43:23.149 18312-18347/? W/dalvikvm﹕ VFY: unable to resolve virtual method 517: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;

08-12 16:43:25.739 18217-18227/? I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.kf.a

08-12 16:43:25.739 18217-18227/? W/dalvikvm﹕ VFY: unable to resolve virtual method 460: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;

08-12 16:43:25.999 18312-18312/? W/GAv4﹕ CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.

08-12 16:43:26.119 18312-18462/? I/AppsFlyer_1.10-378006025﹕ data: uid=1431711915707-8893133370169098795&model=SM-A500G&af_v=a09035880167c91a707b897124818be0db045fd6&app_version_code=103&af_preinstalled=false&lang=English&network=WIFI&currency=INR&android_id=e8fe1e2b95d7effd&firstLaunchDate=2015-05-15_1115%2B0530&installDate=2015-05-15_1115%2B0530&deviceType=user&date2=2015-08-11_0838%2B0530&carrier=IND+airtel&advertiserIdEnabled=false&sdk=19&dkh=PzctUWAy&date1=2015-05-15_1115%2B0530&appsflyerKey=PzctUWAyaZJq5n58YV8C59&counter=656&imei=356320063877429&operator=airtel&fb=86a46bac-ba5a-49f9-972c-744ab987f5ca&isFirstCall=false&product=a5ltedd&af_timestamp=1439378006025&device=a5lte&brand=samsung&app_version_name=1.9.13&channel=Playstore&advertiserId=af7c612c-9a07-420a-9954-c1857a85fd2b

08-12 16:43:26.909 18312-18474/? I/AppsFlyer_1.10﹕ Calling server for attribution url: https://api.appsflyer.com/install_data/v3/com.goibibo-Playstore?devkey=PzctUWAyaZJq5n58YV8C59&device_id=1431711915707-8893133370169098795

08-12 16:43:27.639 18312-18474/? I/AppsFlyer_1.10﹕ AttributionIdFetcher response code: 400 url: https://api.appsflyer.com/install_data/v3/com.goibibo-Playstore?devkey=PzctUWAyaZJq5n58YV8C59&device_id=1431711915707-8893133370169098795

08-12 16:43:36.139 656-656/? D/Finsky﹕ [1] 5.onFinished: Installation state replication succeeded.

Please Help me to solve my problem….

Shirisha Gangula
Shirisha Gangula
5 years ago

what is picasa username and Where should we give Picasa username.

I tried by giving it in AppConst.java but my app is crashed

MY AppConst.java is

public class AppConst {

// Number of columns of Grid View
// by default 2 but user can configure this in settings activity
public static final int NUM_OF_COLUMNS = 2;

// Gridview image padding
public static final int GRID_PADDING = 4; // in dp

// Gallery directory name to save wallpapers
public static final String SDCARD_DIR_NAME = “Awesome Wallpapers”;
// Picasa/Google web album username
public static final String PICASA_USER = “freewallpapersapp”;

// Public albums list url
public static final String URL_PICASA_ALBUMS = “https://picasaweb.google.com/data/feed/api/user/shirishasaikumar?kind=album&alt=json”;

// Picasa album photos url
public static final String URL_ALBUM_PHOTOS = “https://picasaweb.google.com/data/feed/api/user/shirishasaikumar/albumid/_ALBUM_ID_?alt=json”;

// Picasa recenlty added photos url
public static final String URL_RECENTLY_ADDED = “https://picasaweb.google.com/data/feed/api/user/shirishasaikumar?kind=photo&alt=json”;

}

When my app crashing im getting the following in logcat

08-12 16:43:22.389 18251-18251/? W/dalvikvm﹕ VFY: unable to resolve virtual method 537: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;

08-12 16:43:22.459 18251-18251/? W/GAv4﹕ CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.

08-12 16:43:22.839 18312-18312/? I/MultiDex﹕ install

08-12 16:43:22.859 18312-18312/? I/MultiDex﹕ install done

08-12 16:43:23.149 18312-18347/? I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzh

08-12 16:43:23.149 18312-18347/? W/dalvikvm﹕ VFY: unable to resolve virtual method 517: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;

08-12 16:43:25.739 18217-18227/? I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.kf.a

08-12 16:43:25.739 18217-18227/? W/dalvikvm﹕ VFY: unable to resolve virtual method 460: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;

08-12 16:43:25.999 18312-18312/? W/GAv4﹕ CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.

08-12 16:43:26.119 18312-18462/? I/AppsFlyer_1.10-378006025﹕ data: uid=1431711915707-8893133370169098795&model=SM-A500G&af_v=a09035880167c91a707b897124818be0db045fd6&app_version_code=103&af_preinstalled=false&lang=English&network=WIFI&currency=INR&android_id=e8fe1e2b95d7effd&firstLaunchDate=2015-05-15_1115%2B0530&installDate=2015-05-15_1115%2B0530&deviceType=user&date2=2015-08-11_0838%2B0530&carrier=IND+airtel&advertiserIdEnabled=false&sdk=19&dkh=PzctUWAy&date1=2015-05-15_1115%2B0530&appsflyerKey=PzctUWAyaZJq5n58YV8C59&counter=656&imei=356320063877429&operator=airtel&fb=86a46bac-ba5a-49f9-972c-744ab987f5ca&isFirstCall=false&product=a5ltedd&af_timestamp=1439378006025&device=a5lte&brand=samsung&app_version_name=1.9.13&channel=Playstore&advertiserId=af7c612c-9a07-420a-9954-c1857a85fd2b

08-12 16:43:26.909 18312-18474/? I/AppsFlyer_1.10﹕ Calling server for attribution url: https://api.appsflyer.com/install_data/v3/com.goibibo-Playstore?devkey=PzctUWAyaZJq5n58YV8C59&device_id=1431711915707-8893133370169098795

08-12 16:43:27.639 18312-18474/? I/AppsFlyer_1.10﹕ AttributionIdFetcher response code: 400 url: https://api.appsflyer.com/install_data/v3/com.goibibo-Playstore?devkey=PzctUWAyaZJq5n58YV8C59&device_id=1431711915707-8893133370169098795

08-12 16:43:36.139 656-656/? D/Finsky﹕ [1] 5.onFinished: Installation state replication succeeded.

Please help me….

Mostafa Mohamad
Mostafa Mohamad
5 years ago

where I can find albumid?

Right to Recall
5 years ago

Error:Execution failed for task ‘:app:dexDebug’.

> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘C:Program FilesJavajdk1.8.0_45binjava.exe” finished with non-zero exit value 2

Above error is being shown on running the app.

Can you help me in this?

Muhammed Abdullah
Muhammed Abdullah
5 years ago

hello Ravi, thanks for the great tutorial and for the free source code. It always helps beginners like me.
but I need your help in a few things and if you helped me I will click on every ad on your page.
1st thing is:- I want to add some tabs like “websites, about us, etc…” to the navigation slider with the albums Can I and How? I read “Android Sliding Menu using Navigation Drawer” but I couldn’t add another tab in the sliding menu. Any helps?
2nd thing is:- I want to add 3 buttons “share photo, back button” and favourite button “the last one is optional for me” in the FullScreenViewActivity.java and also add it in activity_fullscreen_image.xml . Any helps?
3rd things :- “it is very optional” i want to have the albums in action bar navigation not in slider of the home tab and the tabs that i will add be in the slider How?
Thanks,
Muhammed Abdullah
If anyone can help me please reply to this message

Muhammed Abdullah
Muhammed Abdullah
5 years ago

hello Ravi, thanks for the great tutorial and for the free source code. It always helps beginners like me.
but I need your help in a few things and if you helped me I will click on every ad on your page.
1st
thing is:- I want to add some tabs like “websites, about us, etc…” to
the navigation slider with the albums Can I and How? I read “Android Sliding Menu using Navigation Drawer” but I couldn’t add another tab in the sliding menu. Any helps?
2nd
thing is:- I want to add 3 buttons “share photo, back button” and
favourite button “the last one is optional for me” in the
FullScreenViewActivity.java and also add it in
activity_fullscreen_image.xml . Any helps?
3rd things :- “it is very
optional” i want to have the albums in action bar navigation not in
slider of the home tab and the tabs that i will add be in the slider
How?
Thanks,
Muhammed Abdullah
If anyone can help me please reply to this message

sarun
sarun
5 years ago

How to add a next and previous buttons in FullScreenViewActivity ?
Any help will be appreciated
Thank u

Serdar Koçoğlu
Serdar Koçoğlu
5 years ago

You hide in the code of practice, but you tell me where. Can you tell me where it is.

Nikhil Singh
Nikhil Singh
5 years ago

sir, saved images and there folder is not showing in galary..please if you have any solution about it then help me..:(

Milan
Milan
4 years ago

Thanx Ravi, But I need you help I got an error

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘com.domore.freewallpaper.util.PrefManager com.domore.freewallpaper.app.AppController.getPrefManger()’ on a null object reference

at com.domore.freewallpaper.SplashActivity.onCreate(SplashActivity.java:40)

please, Brol help me to solve out this error as soon as possible

Bishwajit Nepali
Bishwajit Nepali
4 years ago
Reply to  Milan

I have the same problem, I guess there is some error in constants , Let me know if u solved this

Milan
Milan
4 years ago

https://picasaweb.google.com/data/feed/api/user/_PICASA_USER_?kind=album&alt=json

What i need to insert instead of _PICASA_USER_?

how to find the value to get the list of album?

Bishwajit Nepali
Bishwajit Nepali
4 years ago

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘com.domore.freewallpaper.util.PrefManager com.domore.freewallpaper.app.AppController.getPrefManger()’ on a null object reference

I have the same this error if you have make it run please put comment ..what should be kept in google name, Picasa User….??

Ahmad Ryandi
Ahmad Ryandi
4 years ago

ravi can we change the background colour or maybe we can use another photo for the background?
if we can change, how ?
please answer me

Dhaval Asodariya
Dhaval Asodariya
4 years ago

ERROR. with use of Gradle in AndroidStuio

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mountheights.apps.gridviewgalleryexample/com.mountheights.apps.gridviewgalleryexample.SplashActivity}: java.lang.NullPointerException: Attempt to invoke virtual method ‘com.mountheights.apps.gridviewgalleryexample.util.PrefManager com.mountheights.apps.gridviewgalleryexample.app.AppController.getPrefManger()’ on a null object reference

Haitham
Haitham
4 years ago

Can I use this code inside my app? do I have to take license?

Mohd Shah Nawaz
Mohd Shah Nawaz
4 years ago
Reply to  Haitham

I don’t think this will be a problem. He wrote this tutorial to help buddy developers. I myself used most of his code and develop my App. Also, I have written a tutorial for the same.
http://www.geekmentors.com/tutorial/android-free-wallpaper-with-admob-google-analytics-using-recyclerview-and-drawerlayout-from-start-to-finish-part-1/

Mohd Shah Nawaz
Mohd Shah Nawaz
4 years ago

Hi Ravi, This tutorial is great but I have faced some challenges as some of the APIs that you used are depreciated so I have written the tutorial again using RecyclerView and Material Design. I have mentioned you in the beginning of tutorial and provided the links to this tutorial. I hope you won’t mind it. I am a newbie in the Android world. Here is the link to my tutorial in case you want to have a look.
http://www.geekmentors.com/tutorial/android-free-wallpaper-with-admob-google-analytics-using-recyclerview-and-drawerlayout-from-start-to-finish-part-1/

Ravi Tamada
4 years ago

Hi Mohd

Thanks for the updated one.

sarun
sarun
4 years ago

Picasa not returning updated ‘recently added’ content any more
Google is going to kill picasa service soon,is there any way i can fetch recently added content

Mohd Shah Nawaz
Mohd Shah Nawaz
4 years ago
Reply to  sarun

There is a way of doing so but it require a little effort. You will have to download the Desktop Application for Picasa, and you will have to sync the Web Albums with your local directory. This App will create an album something like “Recently Updated” which keep track of the recently added photos. But problem is that Google API returns the album name in Alphabetical order, so this album will not be your first album.

I have done it already but I am not using it, I am just fetching all the albums and displaying the first album.

Aldi Putra
4 years ago

Hi
Cant you give me the link of your tutorial ?
Because i cant acces your site?

Mohd Shah Nawaz
Mohd Shah Nawaz
4 years ago
Reply to  Aldi Putra

Ohh I see. I will check and try to up the site. I will get back to you.

Aldy Putra W
Aldy Putra W
4 years ago

okay, I hope not too long, because I really need it 🙂

Mohd Shah Nawaz
Mohd Shah Nawaz
4 years ago
Reply to  Aldy Putra W

If you need source code of my project I can share it right away. send me your email Id if you require the source code.

Aldy Putra W
Aldy Putra W
4 years ago

this my email : aldyputraw@gmail.com , 🙂

Aldy Putra W
Aldy Putra W
4 years ago

this my email aldyputraw@gmail.com

Fawad khan
Fawad khan
3 years ago

bro send me code too..Fawad2047@gmail.com

Sonagara Shailesh
Sonagara Shailesh
4 years ago

How to remove “recently uploaded” tab from app. I want only album.

Tomas Broten
Tomas Broten
4 years ago

Thank you Ravi your post always
helps so much for me. Please I have only
one album category and I don’t need navigation drawer and splash screen. When
the app starts it fetches that category. Please help me to do that. I will wait
your response

Rahul Pawar
Rahul Pawar
4 years ago

Hi Ravi , Can u plz tell me where can i find those three links of google picasa album..since i found ly 2 and 3 .. i could not find 1st link.. can u please help me out..
thank u..

Mikeli Lekeli
Mikeli Lekeli
4 years ago

i just want to display only one album. How can i do this ?

135
0
Would love your thoughts, please comment.x
()
x