当前位置:三九宝宝网 → 宝宝教育 → 智力培养 → 正文

android中代码是如何实现调用动态壁纸的

更新:01-08 整理:39baobao.com
字体:

[VBA调用API实现打开关闭移动指定的文件]'在模块中定义,注意不能在窗口中定义,插入-模块 Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As St...+阅读

调用后动态壁纸其实是显示在Activity的后面,而Activity则是透明显示,这样就可以看到下面的动态壁纸,如果Activity不是透明的则什么也看不到。代码中有用到两个接口 IWallpaperService mService; IWallpaperEngine mEngine; 我们可以看到该目录下面有三个aidl接口,分别是 interface IWallpaperConnection { void attachEngine(IWallpaperEngine engine); ParcelFileDescriptor setWallpaper(String name); } oneway interface IWallpaperService { void attach(IWallpaperConnection connection, IBinder windowToken, int windowType, boolean isPreview, int reqWidth, int reqHeight); } oneway interface IWallpaperEngine { void setDesiredSize(int width, int height); void setVisibility(boolean visible); void dispatchPointer(in MotionEvent event); void dispatchWallpaperCommand(String action, int x, int y, int z, in Bundle extras); void destroy(); } 定义壁纸管理和壁纸信息变量 private WallpaperManager mWallpaperManager = null; private WallpaperInfo mWallpaperInfo = null; private WallpaperConnection mWallpaperConnection = null; private Intent mWallpaperIntent; 初始化这些变量 mWallpaperManager = WallpaperManager.getInstance(this); mWallpaperInfo = mWallpaperManager.getWallpaperInfo();//如果返回null则说明当前不是动态壁纸 mWallpaperIntent = new Intent(WallpaperService.SERVICE_INTERFACE); mWallpaperIntent.setClassName(mWallpaperInfo.getPackageName(), mWallpaperInfo.getServiceName()); 绑定动态壁纸服务 bindService(mIntent, this, Context.BIND_AUTO_CREATE); IWallpaperService mService;//这里有一个adil接口 在连接监听中试着attach public void onServiceConnected(ComponentName name, IBinder service) { mService = IWallpaperService.Stub.asInterface(service); try { mService.attach(this, view.getWindowToken(), // WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY, WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA, true, root.getWidth(), root.getHeight()); } catch (RemoteException e) { Log.w("", "Failed attaching wallpaper; clearing", e); } }

本文地址:https://www.39baobao.com/show/32_40920.html

以上内容来自互联网,请自行判断内容的正确性。若本站收录的信息无意侵犯了贵司版权,请联系我们,我们会及时处理和回复,谢谢.

以下为关联文档:

VB调用VC写的dll的几种方式总结详细第一种类型:数值传递: 注意:在VB 中,默认变量传递方式为ByRef 为地址,而传递值就是用ByVal,还要注意在C++中, int 类型的变量是32 位的,在VB 中要用long 型变量来配合。 C++:extern...

请问火狐浏览器如何调用windows凭据管理器中的凭据您好!感谢您对火狐产品的支持! 所谓的凭据管理器,并不是用于管理登录任何Internet上的网站和网络,而是用于保存和管理与本机建立了某种特殊关系的登录凭据,比如本地计算机局域网...

matlab如何调用统计工具箱调用统计特工具箱的做法: ①打开matlab; ②点击左下角Start; ③进入Toolbox工具箱; ④选择Statistics; 一、统计工具箱指具有一系列统计相关函数和若干GUI的合集,可以通过点击...

C中如何调用第三方控件CsGL开发OpenGL(1) 链接OpenGL libraries:在Visual C++中先单击Project,再单击Settings,再找到Link单击,最后在Object/library modules 的最前面加上opengl32.lib Glut32.lib Glaux.lib glu32....