壁纸不适合三星设备 [英] Wallpaper not properly fit on Samsung devices

查看:59
本文介绍了壁纸不适合三星设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过应用程序为所有设备设置壁纸,但问题是我的以下方法适用于 Moto、sony、micromax,但不适合 任何 samsung 设备,例如samsung S3、samsung duos、Tab 等,在这些设备中,壁纸放大很多,见截图.

I want to set wallpaper through app for all device but problem is that my following approach work for Moto, sony, micromax but not properly fit for any samsung device like samsung S3, samsung duos, Tab etc, in these devices wallpaper is much zoom see in screenshots.

请指导我解决这个问题.

please guide me for solve this problem.

private void setMyWallpaper() {

    WallpaperManager myWallpaperManager = WallpaperManager
            .getInstance(getApplicationContext());

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    // get the height and width of screen
    int height = metrics.heightPixels;
    int width = metrics.widthPixels;

    Drawable drawable = null;

    if (who.equals("color"))
        drawable = getResources().getDrawable(colorWallpaper[i]);
    else
        drawable = getResources().getDrawable(grayWallpaper[i]);
    Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();

    Bitmap wallpaper = Bitmap.createScaledBitmap(bitmap, width, height,true);
    myWallpaperManager.suggestDesiredDimensions(width, height);
    try {
        myWallpaperManager.setBitmap(wallpaper);
        Log.i("Wall", "Wallpaper set successfully ");
    } catch (IOException e) {
        e.printStackTrace();
    }

}

Micromax 画布截图:-

Micromax canvas screenshot :-

三星 S3 截图:

推荐答案

我使用 call INTENT 代替 WallpaperManager 来解决这个问题,如下所示:

I solve this problem using call INTENT in place of WallpaperManager like this:

//加载文件

File file = new File(getGalleryPath());

if ( file.exists()) {
     Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
     intent.addCategory(Intent.CATEGORY_DEFAULT);
     intent.setDataAndType(Uri.fromFile(file), "image/jpeg");
     intent.putExtra("mimeType", "image/jpeg");
     this.startActivity(Intent.createChooser(intent, "Set as:"));
} else {
     Log.d("TEST", "file not exixts.");
}

//获取图片路径的方法

// method for getting Image path

private static String getGalleryPath() {
    return Environment.getExternalStorageDirectory() + "/" + Environment.DIRECTORY_DCIM + "/MyImages/IMG-20160326-WA0083.jpg";   
}

这篇关于壁纸不适合三星设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆