android转屏换墙纸的实现

来源:互联网 发布:sql根据身份证算周岁 编辑:程序博客网 时间:2024/04/27 01:02
@Overridepublic void onConfigurationChanged(Configuration newConfig) {// TODO Auto-generated method stub        WallpaperManager wpm = (WallpaperManager) this.getSystemService(Context.WALLPAPER_SERVICE);        int res_port_id = com.android.launcher.R.drawable.wallpaper_01;        int res_land_id = com.android.launcher.R.drawable.wallpaper_02;        if(Build.MODEL.equals("ST_P100"))        {if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){        if (wpm.hasResourceWallpaper(res_land_id))         {            try             {                wpm.setResource(res_port_id);            }             catch (IOException e)             {e.printStackTrace();            }        }Log.i("dingchao", "现在是竖屏");}else {        if (wpm.hasResourceWallpaper(res_port_id))         {            try             {                wpm.setResource(res_land_id);            }             catch (IOException e)             {e.printStackTrace();            }        }Log.i("dingchao", "现在是横屏");}//Intent mIntent = new Intent("android.intent.action.USER_CHANGE_WALLPAPER");//mIntent.putExtra("orientation", newConfig.orientation);//sendBroadcast(mIntent);        }super.onConfigurationChanged(newConfig);}

0 0
原创粉丝点击