我已经实现了“将墙纸设置为主屏幕”的实现。但是我没有得到如何将墙纸设置为锁定屏幕以及(主屏幕和锁定)两者。在以下代码中,“如果”部分用于设置为主屏幕。是用于“锁定”和“同时(家庭和锁定)” ..将墙纸设置为锁定以及同时将墙纸设置为“家庭”和“锁定”的逻辑是什么??
private Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
WallpaperManager wallpaperManager = WallpaperManager.getInstance(getApplicationContext());
try{
wallpaperManager.setBitmap(bitmap);
Snackbar.make(rootLayout, "Wallpaper was set", Snackbar.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onBitmapFailed(Exception e, Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
fab按钮代码
fabWallpaper = (FloatingActionButton) findViewById(R.id.fabWallpaper);
fabWallpaper.setOnClickListener(new View.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onClick(View v) {
showInt();
if(ActivityCompat.checkSelfPermission(ViewWallpaperActivity.this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Common.PERMISSION_REQUEST_CODE);
}
else{
Picasso.get()
.load(Common.select_background.getImageLink())
.into(target);
}
}
});