7
回答
android锁屏壁纸如何实现
【腾讯云】学生服务器套餐10元/月 >>>   

想请问下android下的锁屏壁纸是如何实现的,也就如何调用系统里面的“设置锁屏壁纸”这个应用,或者android那个api里面有设置锁屏壁纸的方法或接口之类的

WallpaperManager.getInstance(mContext).setBitmap(bitmap);目前知道用这个方法可以将图片设置为壁纸,但是锁屏壁纸的api没有找到

举报
misly
发帖于6年前 7回/7K+阅
共有7个答案 最后回答: 5年前

In addition to supporting the policies listed in the above table, the Device Administration API lets you do the following:

  • Prompt user to set a new password.
  • Lock device immediately.
  • Wipe the device's data (that is, restore the device to its factory defaults).

引用来自“LiangX”的答案

In addition to supporting the policies listed in the above table, the Device Administration API lets you do the following:

  • Prompt user to set a new password.
  • Lock device immediately.
  • Wipe the device's data (that is, restore the device to its factory defaults).
额,你这是设置密码、设备锁和擦除数据的吧,我是把我当前查看的图片设置为锁屏壁纸啊
@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		File file = new File("mnt/sdcard2/DCIM/Camera/IMG_20120216_160054.jpg");
		Intent intent = createSetAsIntent(Uri.fromFile(file),null);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(Intent.createChooser(intent, "设置壁纸"));
		// file:///mnt/sdcard2/DCIM/Camera/IMG_20120216_160054.jpg
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	public static Intent createSetAsIntent(Uri uri, String mimeType) {
		// Infer MIME type if missing for file URLs.
		if (uri.getScheme().equals("file")) {
			String path = uri.getPath();
			int lastDotIndex = path.lastIndexOf('.');
			if (lastDotIndex != -1) {
				mimeType = MimeTypeMap.getSingleton()
						.getMimeTypeFromExtension(
								uri.getPath().substring(lastDotIndex + 1)
										.toLowerCase());
			}
		}

		Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
		intent.setDataAndType(uri, mimeType);
		intent.putExtra("mimeType", mimeType);
		return intent;
	}
顶部