簡體   English   中英

如何將鎖屏壁紙設置為實時壁紙

[英]How to set lock screen wallpaper to a live one

我正在開發一個android應用程序,我需要將鎖屏牆紙和普通牆紙設置為動畫牆紙。 我使用自定義牆紙服務,並使用新的Intent將其設置為主屏幕。 雖然這適用於主屏幕,但我還沒有找到使其在鎖定屏幕上工作的方法,但我得到的最接近的方法是使其在三星手機上工作。 現在我想知道我是否能做些什么來實現自己的目標。

這是我當前的實現:

Intent intent = new Intent("android.service.wallpaper.CHANGE_LIVE_WALLPAPER");
intent.putExtra("android.service.wallpaper.extra.LIVE_WALLPAPER_COMPONENT", new ComponentName(MainActivity.this, BorderlightWallpaperService.class));
startActivity(intent);

從API級別24開始,他們為WallpaperManager添加了新方法(並更新了文檔)和標志,這些標志和標志使您不僅可以將牆紙設置為主屏幕,還可以將其設置為鎖屏。

要將牆紙設置為鎖屏,請使用新的標志WallpaperManager.FLAG_LOCK,以及采用int方法的一種方法

WallpaperManager.getInstance(this).setStream(inputStream, null, true,WallpaperManager.FLAG_LOCK);

您也可以使用以下方法之一

int setStream (InputStream bitmapData,  Rect visibleCropHint,  boolean allowBackup, int which)

int setResource (int resid, int which)

int setBitmap (Bitmap fullImage, Rect visibleCropHint,  boolean allowBackup,  int which)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM