android开发分享在Rooted Device Android上以编程方式设置dynamic壁纸

是否有可能以某种方式设置dynamic壁纸使用我的应用程序?

我正在开发一个应用程序,目的是在设备上select一些已安装的dynamic壁纸,并将其设置为dynamic壁纸。 这个动作需要通过我的应用程序完成。

正如我在研究,我发现一些答案,这可以通过扎根Android设备来完成?

有人可以帮我解决这个问题吗?

    果冻豆之前的Android操作系统不允许您以编程方式设置dynamic壁纸。 现在果冻豆支持以编程方式更改dynamic壁纸,无需用户交互

    对不起,它打破了无可言状态,但它可以设置一个dynamic壁纸编程方式无需用户交互。 这个需要:

    注:对于项目#3,我用我自己的dynamic壁纸,MyWallpaperService类

    这只能在您的应用程序是系统特权并且在清单中具有此权限的情况下才能完成:

     <uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" /> 

    现在,使用reflection,你可以调用WallpaperManager的隐藏方法来手动设置dynamic壁纸:

     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()); 

    参考源代码:

      以上就是android开发分享在Rooted Device Android上以编程方式设置dynamic壁纸相关内容,想了解更多android开发(异常处理)及android游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/addevelopment/517912.html

      (0)
      上一篇 2020年12月5日
      下一篇 2020年12月5日

      精彩推荐