首页 » 技术分享 » 待机壁纸和锁机壁纸

待机壁纸和锁机壁纸

 
public void SetLockImg(){
		Bitmap bitmap = BitmapFactory.decodeResource(getResources(), mLockScreenImage);	
	    
	    String string = "/data/shared/lockbg.png";
		File file = new File(string);		    	
		BufferedOutputStream bos = null;
		
		if(file.exists())
		{    		
			file.delete();
			if(bitmap==null)
			{
				return;
			}
		}
		
		try {  		

			file.createNewFile();
			file.setReadable(true, false);
			file.setWritable(true, false);
			file.setExecutable(true,false);
			bos = new BufferedOutputStream(new FileOutputStream(file));
	        bitmap.compress(Bitmap.CompressFormat.PNG,100, bos);
	        bos.flush();
	        bos.close();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

public void SetDeskImg(){
		Bitmap bitmap = null;
		bitmap = BitmapFactory.decodeResource(getResources(),mWallpaperImage);
		
		if(bitmap != null)
			try {
				setWallpaper(bitmap);				
			} catch (IOException e) {
				e.printStackTrace();
			}
	}

转载自原文链接, 如需删除请联系管理员。

原文链接:待机壁纸和锁机壁纸,转载请注明来源!

0