Android 中WallpaperManager用法实例 注意:壁纸的设置得加入权限: <uses-permission android:name="android.permission.SET_WALLPAPER..."/ 1、WallpaperManager 对象的获得: wallpaperManager =WallpaperManager.getInstance(this); 2、设置壁纸的方法: 方法一...:wallpaperManager.setBitmap();// 参数 方法二:wallpaperManager.setResource(); // 参数为资源ID 方法三:通过ContextWrapper...wallpaperManager; //墙纸管理器 private int index; // 资源索引 // 绑定服务 public IBinder onBind(Intent...= WallpaperManager.getInstance(WallService.this); // 获取壁纸管理器对象 } // 销毁服务 public void onDestroy
= plus.android.importClass('android.app.WallpaperManager'); //console.log(WallpaperManager...); var Main = plus.android.runtimeMainActivity(); var wallpaperManager...= WallpaperManager.getInstance(Main); //console.log(wallpaperManager);...(, ); wallpaperManager.setBitmap(bitmap);...wallpaperManager.setBitmap(bitmap, null, true, WallpaperManager.FLAG_LOCK); //设置锁屏
null, null)); intent.setData(uri); startActivityForResult(intent, SET_WALLPAPER); 2、通过WallpaperManager...try { WallpaperManager wpm = (WallpaperManager) getActivity().getSystemService( Context.WALLPAPER_SERVICE
author ldm * @date 2016-5-4 下午3:08:56 */ public class SetWallpaperActivity extends Activity { // WallpaperManager...private WallpaperManager wallpaperManager; // 壁纸对应的Drawable private Drawable wallpaperDrawable;...savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.set_wallpaper); // 初始化WallpaperManager...wallpaperManager = WallpaperManager.getInstance(this); wallpaperDrawable = wallpaperManager.getDrawable...OnClickListener() { public void onClick(View view) { try { // 设置壁纸 wallpaperManager.setBitmap
BitmapDrawable bitmap = (BitmapDrawable) getResources().getDrawable(wallpapers[current++]); wallpaperManager...= WallpaperManager.getInstance(MainActivity.this); try { wallpaperManager.setBitmap...wallpapers = new int[]{ R.drawable.background1, R.drawable.background2, R.drawable.background3 }; WallpaperManager...wallpaperManager; int current = 0; @Override protected void onCreate(Bundle savedInstanceState
失败案例 3.1 失败案例1 WallpaperManager wallpaperManager = WallpaperManager.getInstance(MainActivity.this); try...final WallpaperManager wallpaperManager = WallpaperManager.getInstance(ViewWallpaperActivity.this); wallpaperManager.suggestDesiredDimensions...(); final int height = wallpaperManager.getDesiredMinimumHeight(); // 4.缩放图片。...设置壁纸 final WallpaperManager wallpaperManager = WallpaperManager.getInstance(ViewWallpaperActivity.this...wallpaperManager = WallpaperManager.getInstance(context); wallpaperManager.suggestDesiredDimensions
BitmapDrawable bitmap = (BitmapDrawable) getResources().getDrawable(wallpapers[current++]); wallpaperManager...= WallpaperManager.getInstance(MainActivity.this); try { wallpaperManager.setBitmap...int[]{ R.drawable.background1, R.drawable.background2, R.drawable.background3 }; WallpaperManager...wallpaperManager; int current = 0; @Override protected void onCreate(Bundle savedInstanceState
int[] wallpapers = new int[]{ R.drawable.a2, R.drawable.a3, R.drawable.a4 }; WallpaperManager...wallpaperManager; int current = 0; @Override public void onCreate() { super.onCreate...(); wallpaperManager = WallpaperManager.getInstance(this); } @Override public int...flags, int startId) { if (current >= 3) { current = 0; } try { wallpaperManager.setResource
Service { int[] wallpapers = new int[]{ R.drawable.a2, R.drawable.a3, R.drawable.a4 }; WallpaperManager...wallpaperManager; int current = 0; @Override public void onCreate() { super.onCreate();...wallpaperManager = WallpaperManager.getInstance(this); } @Override public int onStartCommand(Intent...intent, int flags, int startId) { if (current = 3) { current = 0; } try { wallpaperManager.setResource
2.5 壁纸切换实现逻辑 /** * 设置壁纸 */ private void setWallpaper(int colorResourceId) { WallpaperManager wallpaperManager...= WallpaperManager.getInstance(mContext); int color = mContext.getResources().getColor(colorResourceId...= WallpaperManager.getInstance(mContext) val color = mContext.resources.getColor(colorResourceId...package com.nim.wallpaper; import android.app.WallpaperManager; import android.content.Context; import...wallpaperManager = WallpaperManager.getInstance(mContext); int color = mContext.getResources
代码: 这里我封装了工具类 package xxxxx.utils; import android.app.Activity; import android.app.WallpaperManager;...Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(),R.drawable.bg_user_top);//设置项目res中的图片 WallpaperManager...manager = WallpaperManager.getInstance(activity); try { manager.setBitmap(bitmap); UiUtil.showToastLong
val wallpaperManager = WallpaperManager.getInstance(this) try { val bitmap = ContextCompat.getDrawable...toBitmap() wallpaperManager.setBitmap(bitmap) } catch (e: Exception) { e.printStackTrace() }...val localIntent = Intent() localIntent.action = WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER localIntent.putExtra...( WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, ComponentName(applicationContext.packageName
R.drawable.author, R.drawable.girl, R.drawable.life }; //定义系统的壁纸管理服务 WallpaperManager...wallpaperManager; //定义当前所显示的壁纸 int current = 0; @Override public void onCreate() {...super.onCreate(); //初始化WallPaperManager wallpaperManager = WallpaperManager.getInstance...if (current >= 3) { current = 0; } try { //改变壁纸 wallpaperManager.setResource
android.view.WindowManagerPolicy.WindowManagerFuncs; import android.view.Gravity; import android.app.WallpaperManager...SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions"; int mdownx,mdowny; boolean ispowerdown=false; private WallpaperManager...filter.addAction(Intent.ACTION_WALLPAPER_CHANGED); context.registerReceiver(mBroadcastReceiver, filter); wpm = (WallpaperManager
在android中:Context.getSystemService就使用了享元模式的原理,其实这个具体方法的实现还使用到了 装饰器模式 1.每个应用组件都可以使用系统提供的众多服务管理对象,如WallpaperManager
用户可以通过这知道系统后台发生了什么 WallpaperManagerService -> WallpaperManager 管理桌面背景的服务,深度定制化桌面系统 AppWidgetService -...PowerManager(电源服务) powermanager WindowManager(窗口管理服务) windowmanager LayoutInflater(布局服务) layoutinflater WallpaperManager...(壁纸管理器) wallpapermanager
Launcher3设置完自定义壁纸(系统自带壁纸不会记录)的时候,会在com.android.launcher3.WallpaperCropActivity.xml中记录被设置壁纸的分辨率,并提交分辨率给WallpaperManager...updateWallpaperDimensions(),它被WallpaperCropActivity.java的setWallpaper()调用; Launcher3每次旋转后会重新执行onCreate(),同时会提交当前壁纸的分辨率给WallpaperManager
如很多硬件相关的系统服务管理类和服务:ServiceManager、SensorManager、WindowManagerGlobal、WallpaperManager、AccessibilityManager
· 升级的WallpaperManager. 附加说明, 如果你的应用相提供Live Wallpapers的功能, 你必须记得增加一个 元素到你的应用manifest里面.
6.壁纸相关操作:这个不是成员变量提供的,WallpaperManager是系统Service一种,所以是SystemService提供的。
领取专属 10元无门槛券
手把手带您无忧上云