Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8377705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:44:20+00:00 2026-06-09T15:44:20+00:00

Below are my codes, I want to use wallpaper manager to set as wallpaper.

  • 0

Below are my codes, I want to use wallpaper manager to set as wallpaper. I’m using Universal Image Loader, but i dont know how implement wallpaper manager. My setWall() is not working, kinda confusing.

    import android.graphics.Bitmap;
    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.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.view.animation.Animation;
    import android.view.animation.AnimationUtils;
    import android.widget.ImageView;
    import android.widget.ProgressBar;
    import android.widget.Toast;

    import com.nostra13.universalimageloader.core.DisplayImageOptions;
    import com.nostra13.universalimageloader.core.assist.FailReason;
    import com.nostra13.universalimageloader.core.assist.ImageLoadingListener;
    import com.nostra13.universalimageloader.core.assist.ImageScaleType;


    public class ImageActivity extends BaseActivity {

        private DisplayImageOptions imageoptions;

        private ViewPager imagepager;

        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            setContentView(R.layout.imagepager);


            Bundle bundle = getIntent().getExtras();
            String[] imageUrls = bundle.getStringArray(Extra.IMAGES);
            int pagerPosition = bundle.getInt(Extra.IMAGE_POSITION, 0);
            imageoptions = new DisplayImageOptions.Builder()
                .showImageForEmptyUri(R.drawable.noimage)
                .cacheOnDisc()
                .imageScaleType(ImageScaleType.EXACT)
                .build();

            imagepager= (ViewPager) findViewById(R.id.imagepager);
            imagepager.setAdapter(new ImagePagerAdapter(imageUrls));
            imagepager.setCurrentItem(pagerPosition);
        }


 public void setWall() {

    WallpaperManager myWallpaperManager
     = WallpaperManager.getInstance(getApplicationContext());
    try {
     myWallpaperManager.setResource(R.drawable.app_icon); //<--My app just set my app icon image as wallpaper, this is not I wanted. I wanted to set my selected image as wallpaper 
    } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }

}

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.setWall:
                setWall();
                return true;
            default:
                return false;
        }
    }

@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();
        }

        @Override
        public void destroyItem(View container, int position, Object object) {
            ((ViewPager) container).removeView((View) object);
        }

        @Override
        public void finishUpdate(View container) {
        }

        @Override
        public int getCount() {
            return images.length;
        }

        @Override
        public Object instantiateItem(View view, int position) {
            final View imageLayout = 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, imageoptions, 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(Bitmap loadedImage) {
                    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;
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view.equals(object);
        }

        @Override
        public void restoreState(Parcelable state, ClassLoader loader) {
        }

        @Override
        public Parcelable saveState() {
            return null;
        }

        @Override
        public void startUpdate(View container) {
        }
    }





}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:44:22+00:00Added an answer on June 9, 2026 at 3:44 pm

    Instead of myWallpaperManager.setResource(0); Why didn’t you use the myWallpapaerManager.setResource(R.drawable.yourimage)

    Have a look at Wallpapaer Manager example. Hope this helps you lot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the code below, I don't want to use instanceof to know the type
these below codes give whole data of my Rehber datas. But if i want
I don't know what is the error behind the codes below, All I want
i want to use below codes. So i have a generic list<MyClass> i think
I am using below code where i don't want to use JPEGEncodedImage.encode because it
I want to replace some strings by other one. I use below codes: $mc
In my application I am using JSF 1.2. I dont want to use facelets
As a PHP developer, I always use the code below whenever I want to
I want to get only data until the <img tag. my codes are below:
I want to know if the below code: <?php printf (%s, $some_variable); ?> is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.