Wallpaper Manager problem?

Hi @Taifun, how can I set the wallpaper of the home screen in extension. I am using the wallpaper manager class.

This is what I did-

  @SimpleFunction(description = "")
  public void SetWallpaper(String path) {
    WallpaperManager manager = WallpaperManager.getInstance(); /** What is the thing which I want keep as the instance*/
    try {
      manager.setResource(); /** How can I keep the path as the resource?*/
    } catch (Exception e) {

The questions are there in the code itself.

Thank you..... :smile:

1 Like

Did you see this?


This will solve all your problems :

1.Import this :

import com.google.appinventor.components.annotations.UsesPermissions;
import android.app.WallpaperManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import java.io.IOException;

2.Add Permission

Add this line under @DesignerComponent

@UsesPermissions(permissionNames = "android.permission.SET_WALLPAPER")

3.Add the code that I fixed

    @SimpleFunction(description = "")
    public void SetWallpaper(String imagePath) {
      Bitmap myBitmap = BitmapFactory.decodeFile(imagePath);
      WallpaperManager manager = WallpaperManager.getInstance(container.$context());
      } catch (IOException e) {
         Toast.makeText(container.$context(), "Error!", Toast.LENGTH_SHORT).show();

Aix Source Code :
WallpaperNew.txt (1.6 KB)

To use the extension, you have to do something like this :



And I have tested the code and it works 100% so you don't need to worry. Thank you :star_struck: :+1:

1 Like

Thank you very very very much :smiling_face_with_three_hearts: :star_struck: :kissing_heart:


Your missing read permission in the extension. As your using image picker it's okay

1 Like

Oh, I am sorry :sweat_smile:
And I think it will work even if it doesn't use read permission

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.