问题描述
我创建通过以下我的拳头动态壁纸。但我发现了错误不能得到解决或不是一个字段
这两行
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
而努力才达到这个
Intent intent = new Intent( WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
new ComponentName(this, LiveWallService.class));
和编译器提供这些suggessions:
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...?
推荐答案
WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER仅在API等级16(4.1.2)补充道。也许你已经设定目标SDK版本比16低的东西?
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?
低于API级别16,你只能发送用户使用意图的行动WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER整体LWP选择屏幕,并告诉他从那里选择壁纸。你可以设置你的code以下列方式:
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
这篇关于得到错误的WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!