Android Studio Set Wallpaper Programmatically

In this Android Studio article iam going to show you how to Set Wallpaper Programmatically. so  for good explanation you can watch the video for this article.

 

 

Also check my Android Development Courses

 

Now lets get started!

 

1: First of all create a new project in your Android Studio, and choose Empty Activity also iam using API 20 for this project.

2: OK after creating project in android studio open you AndroidManifest.xml file and you need to add this persimmon to the manifest file.

 

 

So after adding your AndroidManifest.xml will look like this.

 

 

 

3: OK now open your activitiy_main.xml and we are going to add a button in our this file

 

 

 

4: So now open your MainActivity.java, first let me add the code and after i explain the codes

 

 

 

OK at the top first we have created the object of our button, and after that we have find the id of that button also we have created an onClickListener for the button, because i want when a user click on the button i want to change the wallpaper of my phone or virtual emulator. And this is the method for  Wallpaper changing programmatically. also you need to add an image in your drawable folder.

 

 

 

 

 

So now run the code and this is the result wallpaper changed

Android Studio Set Wallpaper Programmatically
Android Studio Set Wallpaper Programmatically

 

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Share via
Copy link
Powered by Social Snap
×