以某種方式使用我的應用程序以編程方式設置動態壁紙有可能嗎?以編程方式在植根設備上設置動態壁紙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