Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error at WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER

I'm creating my fist Live wallpaper by following this tutorial. But i'm getting error can not be resolved or is not a field on these two lines

WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT

while trying to achive this

Intent intent = new Intent( WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
            new ComponentName(this, LiveWallService.class));

And compiler provides these suggessions:

WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER
WallpaperManager.COMMAND_DROP
WallpaperManager.COMMAND_SECONDARY_TAP
WallpaperManager.COMMAND_TAP
WallpaperManager.WALLPAPER_PREVIEW_META_DATA

Is any thing wrong...?

like image 436
Arsalan Avatar asked Jan 14 '13 10:01

Arsalan


1 Answers

WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER was only added in API Level 16 (4.1.2). Perhaps you have set your target SDK version to something lower than 16?

Below API level 16, you can only send the user to the overall LWP selection screen using intent action WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER, and tell him to select your wallpaper from there. You could set up your code in the following way:

Intent i = new Intent();

if(Build.VERSION.SDK_INT >= 16)
{
    i.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
    i.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName(packageName, canonicalName));
}
else
{
    i.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
}

// send intent
like image 138
Thrakbad Avatar answered Oct 21 '22 14:10

Thrakbad