Search in sources :

Example 1 with WallpaperManager

use of android.app.WallpaperManager in project android_packages_apps_Launcher2 by CyanogenMod.

the class UserInitializeReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    final Resources resources = context.getResources();
    // Context.getPackageName() may return the "original" package name,
    // com.android.launcher2; Resources needs the real package name,
    // com.android.launcher. So we ask Resources for what it thinks the
    // package name should be.
    final String packageName = resources.getResourcePackageName(R.array.wallpapers);
    ArrayList<Integer> list = new ArrayList<Integer>();
    addWallpapers(resources, packageName, R.array.wallpapers, list);
    addWallpapers(resources, packageName, R.array.extra_wallpapers, list);
    WallpaperManager wpm = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE);
    for (int i = 1; i < list.size(); i++) {
        int resid = list.get(i);
        if (!wpm.hasResourceWallpaper(resid)) {
            try {
                wpm.setResource(resid);
            } catch (IOException e) {
            }
            return;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Resources(android.content.res.Resources) IOException(java.io.IOException) WallpaperManager(android.app.WallpaperManager)

Example 2 with WallpaperManager

use of android.app.WallpaperManager in project android_packages_apps_Launcher2 by CyanogenMod.

the class WallpaperChooserDialogFragment method selectWallpaper.

private void selectWallpaper(int position) {
    try {
        WallpaperManager wpm = (WallpaperManager) getActivity().getSystemService(Context.WALLPAPER_SERVICE);
        wpm.setResource(mImages.get(position));
        Activity activity = getActivity();
        activity.setResult(Activity.RESULT_OK);
        activity.finish();
    } catch (IOException e) {
        Log.e(TAG, "Failed to set wallpaper: " + e);
    }
}
Also used : Activity(android.app.Activity) IOException(java.io.IOException) WallpaperManager(android.app.WallpaperManager)

Example 3 with WallpaperManager

use of android.app.WallpaperManager in project ADWLauncher2 by boombuler.

the class Launcher method setWallpaperDimension.

private void setWallpaperDimension() {
    WallpaperManager wpm = (WallpaperManager) getSystemService(WALLPAPER_SERVICE);
    Display display = getWindowManager().getDefaultDisplay();
    boolean isPortrait = display.getWidth() < display.getHeight();
    final int width = isPortrait ? display.getWidth() : display.getHeight();
    final int height = isPortrait ? display.getHeight() : display.getWidth();
    wpm.suggestDesiredDimensions(width * WALLPAPER_SCREENS_SPAN, height);
}
Also used : WallpaperManager(android.app.WallpaperManager) Display(android.view.Display)

Example 4 with WallpaperManager

use of android.app.WallpaperManager in project robolectric by robolectric.

the class ShadowWallpaperManagerTest method getInstance_shouldCreateInstance.

@Test
public void getInstance_shouldCreateInstance() {
    WallpaperManager manager = WallpaperManager.getInstance(RuntimeEnvironment.application);
    assertThat(manager).isNotNull();
}
Also used : WallpaperManager(android.app.WallpaperManager) Test(org.junit.Test)

Example 5 with WallpaperManager

use of android.app.WallpaperManager in project robolectric by robolectric.

the class ShadowWallpaperManagerTest method sendWallpaperCommand_shouldNotThrowException.

@Test
public void sendWallpaperCommand_shouldNotThrowException() {
    WallpaperManager manager = WallpaperManager.getInstance(RuntimeEnvironment.application);
    manager.sendWallpaperCommand(null, null, 0, 0, 0, null);
}
Also used : WallpaperManager(android.app.WallpaperManager) Test(org.junit.Test)

Aggregations

WallpaperManager (android.app.WallpaperManager)28 IOException (java.io.IOException)14 Bitmap (android.graphics.Bitmap)9 Intent (android.content.Intent)5 Rect (android.graphics.Rect)5 Bundle (android.os.Bundle)4 Handler (android.os.Handler)4 DisplayMetrics (android.util.DisplayMetrics)4 WindowManager (android.view.WindowManager)4 Activity (android.app.Activity)3 Context (android.content.Context)3 Matrix (android.graphics.Matrix)3 Display (android.view.Display)3 InputStream (java.io.InputStream)3 Test (org.junit.Test)3 Application (android.app.Application)2 ProgressDialog (android.app.ProgressDialog)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 Resources (android.content.res.Resources)2 Canvas (android.graphics.Canvas)2