Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
button.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               setBackgroundImage();

           }
       });
   }

   private void setBackgroundImage() {
       Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
       WallpaperManager manager =  WallpaperManager.getInstance(getApplicationContext());

       try {
           manager.setBitmap(bitmap);
           Toast.makeText(getApplicationContext(), "Set Wallpaper Successfully ", Toast.LENGTH_SHORT).show();
       }
       catch (IOException e)
       {
           Toast.makeText(this, "Wallpaper not load yet!", Toast.LENGTH_SHORT).show();
       }


What I have tried:

button.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               setBackgroundImage();

           }
       });
   }

   private void setBackgroundImage() {
       Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
       WallpaperManager manager =  WallpaperManager.getInstance(getApplicationContext());

       try {
           manager.setBitmap(bitmap);
           Toast.makeText(getApplicationContext(), "Set Wallpaper Successfully ", Toast.LENGTH_SHORT).show();
       }
       catch (IOException e)
       {
           Toast.makeText(this, "Wallpaper not load yet!", Toast.LENGTH_SHORT).show();
       }
Posted
Comments
Richard MacCutchan 14-May-22 4:12am    
And?
What happens when you run this code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900