停止/开始动态壁纸服务

时间:2015-01-16 16:14:14

标签: android live-wallpaper

如何以编程方式停止并启动android中的动态壁纸服务?

此代码帮助我发送用户从列表中选择我的动态壁纸

if (Build.VERSION.SDK_INT > 15)
        {
            i.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
            String pkg = WallpaperService.class.getPackage().getName();
            String cls = WallpaperService.class.getCanonicalName();
            i.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName(pkg, cls));
        }
        else
        {
            i.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
        }
        startActivityForResult(i, 0);

有没有办法以编程方式更改用户的动态壁纸?

1 个答案:

答案 0 :(得分:0)

如果您使用的API级别低于15的测试设备,将无法以您希望的方式更改动态壁纸。你的代码完全没问题。只需测试API级别大于15/16的设备即可。

相关问题