gpt4 book ai didi

android - 在 WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER 出现错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:26:31 24 4
gpt4 key购买 nike

我正在通过关注 this 创建我的拳头动态壁纸教程。但是我在这两行上收到错误 can not be resolved or is not a field

WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPERWallpaperManager.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));

编译器提供了这些建议:

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

有什么问题吗...?

最佳答案

WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER 仅在 API 级别 16 (4.1.2) 中添加。也许您已将目标 SDK 版本设置为低于 16?

在 API 级别 16 以下,您只能使用 Intent 操作 WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER 将用户发送到整个 LWP 选择屏幕,并告诉他从那里选择您的壁纸。您可以按以下方式设置代码:

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

关于android - 在 WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER 出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14317167/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com