Add image from cache-memory to android wallpaper
===

I have application where images downloads from internet (**arrays.xml**) and then shown in **Pager Adapter** consequentially. I need to set the desired image to android wallpaper with help button. **But i don't understand how add image from cache-memory to wallpaper** (image **not stored on the SDcard**) **?**
 Images downloading from **arrays.xml** file:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <string-array name="heavy_images">
            <item>https://images-url.com/01.jpg</item>
            <item>https://images-url.com/02.jpg</item>
            <item>https://images-url.com/03.jpg</item>
            <item>https://images-url.com/04.jpg</item>
            <item>https://images-url.com/05.jpg</item>
     </string-array>
    
    </resources>

Then images shown in **Pager Adapter**:

    import android.os.Bundle;
    import android.os.Parcelable;
    import android.support.v4.view.PagerAdapter;
    import android.support.v4.view.ViewPager;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.view.animation.Animation;
    import android.view.animation.AnimationUtils;
    import android.widget.Button;
    import android.widget.FrameLayout;
    import android.widget.ImageView;
    import android.widget.ProgressBar;
    import android.widget.Toast;
    
    public class ImagePagerActivity  extends BaseActivity  {
    
    	private ViewPager pager;
    
    	private DisplayImageOptions options;
    	
    	public void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.ac_image_pager);
    
    		Bundle bundle = getIntent().getExtras();
    		String[] imageUrls = bundle.getStringArray(Extra.IMAGES);
    		int pagerPosition = bundle.getInt(Extra.IMAGE_POSITION, 0);
    
    		options = new DisplayImageOptions.Builder()
    			.showImageForEmptyUri(R.drawable.image_for_empty_url)
    			.cacheOnDisc()
    			.imageScaleType(ImageScaleType.EXACT)
    			.build();
    
    		pager = (ViewPager) findViewById(R.id.pager);
    		pager.setAdapter(new ImagePagerAdapter(imageUrls));
    		pager.setCurrentItem(pagerPosition);
       		
            	}
    
    	@Override
    	protected void onStop() {
    		imageLoader.stop();
    		super.onStop();
    	}
    
    	private class ImagePagerAdapter extends PagerAdapter {
    
    		private String[] images;
    		private LayoutInflater inflater;
    		 
    		ImagePagerAdapter(String[] images) {
    			this.images = images;
    			inflater = getLayoutInflater();
    		}
    
    		
    		public void destroyItem(View container, int position, Object object) {
    			((ViewPager) container).removeView((View) object);
    		}
    
    		
    		public void finishUpdate(View container) {
    		}
    
    		
    		public int getCount() {
    			return images.length;
    		}
    
    		
    		public Object instantiateItem(View view, int position) {
    			final FrameLayout imageLayout = (FrameLayout) inflater.inflate(R.layout.item_pager_image, null);
    			final ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);
    			final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
    
    			imageLoader.displayImage(images[position], imageView, options, new ImageLoadingListener() {
    				
    				public void onLoadingStarted() {
    					spinner.setVisibility(View.VISIBLE);
    				}
    
    				
    				public void onLoadingFailed(FailReason failReason) {
    					String message = null;
    					switch (failReason) {
    						case IO_ERROR:
    							message = "Input/Output error";
    							break;
    						case OUT_OF_MEMORY:
    							message = "Out Of Memory error";
    							break;
    						case UNKNOWN:
    							message = "Unknown error";
    							break;
    					}
    					Toast.makeText(ImagePagerActivity.this, message, Toast.LENGTH_SHORT).show();
    
    					spinner.setVisibility(View.GONE);
    					imageView.setImageResource(android.R.drawable.ic_delete);
    				}
    
    				
    				public void onLoadingComplete() {
    					spinner.setVisibility(View.GONE);
    					Animation anim = AnimationUtils.loadAnimation(ImagePagerActivity.this, R.anim.fade_in);
    					imageView.setAnimation(anim);
    					anim.start();
    				}
    
    				
    				public void onLoadingCancelled() {
    					// Do nothing
    				}
    			});
    
    			((ViewPager) view).addView(imageLayout, 0);
    			return imageLayout;
    		}
    
    		
    		public boolean isViewFromObject(View view, Object object) {
    			return view.equals(object);
    		}
    
    		
    		public void restoreState(Parcelable state, ClassLoader loader) {
    		}
    
    		
    		public Parcelable saveState() {
    			return null;
    		}
    
    		
    		public void startUpdate(View container) {
    		}
    	}
    }

**ac_image_pager.xml**


    <?xml version="1.0" encoding="utf-8"?>
            <android.support.v4.view.ViewPager
         xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

**item_pager_image.xml**

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:padding="1dip">
    
        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:adjustViewBounds="true" />
    
        <ProgressBar
            android:id="@+id/loading"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:visibility="gone" />
    
    </FrameLayout>
            
        
 Thanks.