以某种方式使用我的应用程序以编程方式设置动态壁纸有可能吗?以编程方式在植根设备上设置动态壁纸Android
我正在研究一个应用程序,她的目的是在设备上选择一些已安装的动态壁纸并将其设置为动态壁纸。此操作需要通过我的应用程序完成。
正如我在研究中发现一些答案,这可以通过生根Android设备来完成?
有人可以帮我解决这个问题吗?
以某种方式使用我的应用程序以编程方式设置动态壁纸有可能吗?以编程方式在植根设备上设置动态壁纸Android
我正在研究一个应用程序,她的目的是在设备上选择一些已安装的动态壁纸并将其设置为动态壁纸。此操作需要通过我的应用程序完成。
正如我在研究中发现一些答案,这可以通过生根Android设备来完成?
有人可以帮我解决这个问题吗?
Jelly Bean之前的Android操作系统不允许您以编程方式设置动态壁纸。 现在的果冻豆支持改变程式设计的动态壁纸,而无需用户交互
对不起打破它的反对票塞耶斯,但它是可以设置动态壁纸编程WITHOUT用户交互。它要求:
注意:对于项目#3,我使用了我自己的动态壁纸,MyWallpaperService类
此,如果您的应用程序是系统特权,有此权限的清单只能做:
<uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" />
现在,使用反射,你可以叫WallpaperManager的隐藏方法来手动设置动态壁纸:
WallpaperManager manager = WallpaperManager.getInstance(context);
Method method = WallpaperManager.class.getMethod("getIWallpaperManager", null);
Object objIWallpaperManager = method.invoke(manager, null);
Class[] param = new Class[1];
param[0] = ComponentName.class;
method = objIWallpaperManager.getClass().getMethod("setWallpaperComponent", param);
//get the intent of the desired wallpaper service. Note: I created my own
//custom wallpaper service. You'll need a class reference and package
//of the desired live wallpaper
Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE);
intent.setClassName(context.getPackageName(), MyWallpaperService.class.getName());
//set the live wallpaper (throws security exception if you're not system-privileged app)
method.invoke(objIWallpaperManager, intent.getComponent());
参考的源代码:
你能请张贴一些例子,如何做到这一点?我通过我的应用程序列出所有动态壁纸,并准备好了它们的包名,那么如何停止当前的LiveWallpaper并启动一个新的? – Naskov
请看看http://stackoverflow.com/questions/12842924/how-do-i-move-to-live-wallpaper-preview-from-app –
这个问题是关于设置你自己的活Wapplaper,但我我问通过我的应用程序更改已安装的动态壁纸?你能在这里回答吗? – Naskov