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;
}
}
}
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);
}
}
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);
}
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();
}
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);
}
Aggregations