Creating a simple wallpaper application in android

I am new to Android. I would like to know how to create an application for simple wallpaper in android? Any link or example would be appreciated.

Thanks in advance!

+5
source share
2 answers

read the textbook cornboyz on youtube.

The guy teaches everything from ground level.

I am sure this is what you are looking for. Good luck.

+2
source

The following code will help you create an application to install WallPaper.

package com.example.SetWallpaper;

import java.io.IOException;
import android.app.Activity;
import android.app.WallpaperManager;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class SetWallpaper extends Activity {
    Bitmap bitmap;
    int lastImageRef;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button buttonSetWallpaper = (Button)findViewById(R.id.set);
        ImageView imagePreview = (ImageView)findViewById(R.id.preview);
        imagePreview.setImageResource(R.drawable.five);

        buttonSetWallpaper.setOnClickListener(new Button.OnClickListener(){
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                WallpaperManager myWallpaperManager 
                = WallpaperManager.getInstance(getApplicationContext());
                try {
                        myWallpaperManager.setResource(R.drawable.five);
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
            }});
     }
}

In the manifest file, add the following permission

<uses-permission android:name="android.permission.SET_WALLPAPER">

layout.xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    >

    <Button
        android:id="@+id/set"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/btn" />

    <ImageView
        android:id="@+id/preview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/hello_world" />

</LinearLayout> 

More details: http://www.edumobile.org/android/android-beginner-tutorials/setting-an-image-as-a-wallpaper/

+8
source

All Articles