How to set live wallappers?

edited March 16 in Android Mode

If I develope a normal android app, and I have the apk of a live wallapper saved into a folder of my normal app, how can I set/preview the live wallapper from the normal app?

I have coded some android live wallappers with processing in the mode showed in this image Immagine but the wallappers i create can be set or previwed only by an external app.

Answers

  • No, i have already read that. It doesn't concern my question

  • Once you are satisfied with the transition and easing times, you need to replace size(400, 400) with fullScreen() before running the sketch on the device to make sure that the wallpaper uses the entire screen of the device.

    After the wallpaper sketch has been installed on the device, it won't show up right away. You need to....

    So my understanding is that you could run your wallpaper as any other app only if you set it to run as an app. If you set it as a wallpaper, then you will have to load it on your phone and go through your device's wallpaper selector.

    Kf

  • I know this, but i don't want to create a simple live wallapper to be set by the android wallapper selector. I want to create an app that allows me to set my live wallappers saved in a folder of my app

  • http://stackoverflow.com/questions/20053919/programmatically-set-android-phones-background

    that's about images and from 2013 so i've no idea how useful it is.

    google 'set android wallpaper programatically'. answer will probably involve the WallpaperManager class and the SET_WALLPAPER permission.

  • that said, i'm seeing a lot of things saying that it's not possible for live wallpapers. and that the best you can do is to call the wallpaper chooser for the user to choose. you cannot force one without user input.

  • Thank you @koogs but that link isn't explicative enough

  • edited March 12

    @sarrio===

    @koogs is right; you cannot change wallpaper yourself (your app): only the user can do that and that is normal! - You can only create a new live wallpaper then "suggest" to the user to use it (showing the beautiful result in your app...) and asking to open the wallpaper selector service...

  • Yes @akenaton, that's what I want. Now my question is : the live wallapper must be installed on the sistem to be seen from the live wallapper selector. How can a normal app install a live wallapper? And how can i set some parameters from the normal app?

  • edited March 16

    @sarrio===

    Sorry, till now i never used the android processing mode for wallpaper; i have tried today with the example given (circles); at the end i get only an alert message saying that i have to use the selector; not time enough to understand how this lib is supposed to run

    yet i know how to set wallpaper wit android native code; here a snippet you can try (with your image)::

    //Manifest permissions set wallpaper && wallpaper hints

        import android.os.Looper;
        import android.content.Intent;
        import android.content.Context;
        import android.content.res.AssetManager;
        import android.app.WallpaperManager;
        import android.util.DisplayMetrics;
        import android.graphics.BitmapFactory;
        import android.graphics.Bitmap;
    
    
        Bitmap bitmap;
        Looper loop;
    
        void settings(){
    
          fullScreen();
        }
    
    
    
        void setup(){
         background(255,0,0); 
         orientation(PORTRAIT);
        loop.prepare();
    
          bitmap =  getBitmapFromAsset(getActivity().getApplicationContext(), "myimage.jpg");///change to your image, i think png is better
    
         if(bitmap !=null){
         setWallpaper();
        getActivity().finish();
         }
        };
    
        public void setWallpaper(){
    
        DisplayMetrics metrics = new DisplayMetrics(); 
            getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    
            int height = metrics.heightPixels; 
            int width = metrics.widthPixels;
                    //Bitmap bitmap = BitmapFactory.decodeStream(getResources().openRawResource(R.id.image));
    
            WallpaperManager wallpaperManager = WallpaperManager.getInstance(getActivity().getApplicationContext()); 
              try {
                      wallpaperManager.setBitmap(bitmap);
    
                      wallpaperManager.suggestDesiredDimensions(width, height);
    
    
                  } catch (IOException e) {
                          e.printStackTrace();
                   }
    
        };
    
        public Bitmap getBitmapFromAsset(Context context, String filePath) {
            AssetManager assetManager = context.getAssets();
    
            InputStream istr;
            bitmap = null;
            try {
                istr = assetManager.open(filePath);
                bitmap = BitmapFactory.decodeStream(istr);
            } catch (IOException e) {
                // handle exception
            }
    
            return bitmap;
        }
    
    
    
        void draw(){
    
    
        }
    
        void mouseReleased(){///here this method is useless, yet try it perhaps with //processing wallpaper; of course if you want to use it uncomment finish() in //setup();
    
        Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
           getActivity().startActivity(intent);
        }
    
  • Thank you @akenaton , but i need to set a LIVE wallapper, not an image

  • edited March 16 Answer ✓

    @sarrio=== that is the same (supposing that you have already your wpm installed) - and of course in this case all my code for bitmap is useless)

    Intent intent = new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER); getActivity().startActivity(intent);

    this works easily with AS or eclipse; the problem i see is that it seems that p5 closes the app with its dialog; if it is so i cannot see when i can call the intent without modifying the library itself!

Sign In or Register to comment.