简体   繁体   English

壁纸setbitmap显示黑屏android

[英]Wallpaper setbitmap displays black screen android

When using serBitmap through WallpaperManager ie., wallpaperManager.setBitmap(wallpaperBitmap);通过 WallpaperManager 使用 serBitmap 时,即 wallpaperManager.setBitmap(wallpaperBitmap); I am getting black screen when new wallpaper been set.设置新壁纸时出现黑屏。 How to remove the black screen when transition from old wallpaper to new wallpaper?从旧壁纸过渡到新壁纸时如何去除黑屏?

From where this black screen been displayed in aosp 10 ?这个黑屏从哪里显示在aosp 10中?

Below is the code snippet:下面是代码片段:

setUserWallpaper(this,"test");

private void setUserWallPaper(final Context context, final String userName) {
        setUserWallpaperRunnable =
            new Runnable() {
                @Override
                public void run() {
                    Log.i(TAG, "setUserWallPaper() run");
                    InputStream in = null;
                    OutputStream out = null;
                    try {
                        in = new BufferedInputStream(
                            context.getContentResolver()
                            .openInputStream(
                                Uri.parse(
                                    "content://test.app.personalization.provider/" +
                                    "wall_paper" +
                                    "?user=" +
                                    userName +
                                    "&encryption=false"))
                            );
                        Bitmap wallpaperBitmap = BitmapFactory.decodeStream(in);
                        if(wallpaperBitmap != null){
                            WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
                            wallpaperManager.setBitmap(wallpaperBitmap);
                        } else {
                            Log.i(TAG, "user wallpaper is null.");
                        }
                        Log.i(TAG, "setUserWallPaper() end");
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        try {
                            if (in != null) {
                                in.close();
                            }
                            if(out != null) {
                                out.close();
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            };
        sUserCustomizeWorker.post(setUserWallpaperRunnable);
    }

I know this bug.我知道这个错误。 Problem: Bitmap is too big for wallpaper so you have to rescale the bitmap.问题: Bitmap对于壁纸来说太大了,所以你必须重新调整 bitmap。

Rule: bitmap width < device width * 2 and bitmap height < device height * 2 .规则: bitmap width < device width * 2 and bitmap height < device height * 2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM