How to Build a Wallpaper Android App
1.Open Android Studio.
2.Click on Text.
3.Change Relative Layout to Linear Layout and the orientation as Vertical.
4.Add the Button,
Give the id and other things.
5.Add Image View, match_parent and id as ‘img’
6.Paste the drawable image file on the drawable folder
7.Go to the Main activity. Show the Button and the image view.
8.Show the image view and button in the Java code. Add btn.setOnClickListener and OnClickListener method.
9.Add Wallpaper manager. Give a variable name. Here it is given as ‘wallmgr’
10.Capture the image into the wallpaper by wallmgr.SetResource (R.drawable/wall1) [the image name as set here]. In case you get an error, add a ‘+’ before R.drawable
11.Put catch (IOException E)
12.Go to AndroidManifest.xml
13.Give the permission to access the wallpaper, then SET_WALLPAPER
14. Run it on the Android device. Go to the Wallpaper app and tap on the Set As button.
Complete Code to Build a Wallpaper Android Application
app > res > layout > activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schema.android.com/apk/res/android"
xmlns:app="http://schema.android.com/apk/res-auto"
xmlns:tools="http://schema.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:orientation="vertical"
tools:context="com.stechies.wallpaperapp.MainActivity">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Set As Wallpapper"
android:id="@+id/setwell"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/img"
android:src="@drawable/wall1"/>
</LinearLayout>
app >AndroidManifest.xml> java> com.stechies.wallpaperapp
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schema.android.com/apk/res/android"
package="com.stechies.wallpaperapp">
<uses-permission android:name="android.permission.SET_WELLPAPER" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Wallpapper App"
android:supportRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
app > java > com.stechies.wallpaperapp.MainActivity > MainActivity.java
app>manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schema.android.com/apk/res/android"
package="com.stechies.wallpaperapp">
<uses-permission android:name="android.permission.SET_WELLPAPER" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Wallpapper App"
android:supportRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>