2015-08-25 2 views
0

Je veux mettre fond d'écran par application pour tous les appareils mais le problème est que mon travail d'approche suivante pour Moto, sony, Micromax mais pas ajuster correctement pour tout appareil Samsung comme Samsung S3 , samsung duos, Tab etc, dans ces appareils fond d'écran est beaucoup zoom voir dans les captures d'écran.Wallpaper pas correctement en forme sur les appareils Samsung

veuillez me guider pour résoudre ce problème.

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(); 
    } 

} 

toile Micromax capture d'écran: - Micromax canvas screenshot

Samsung S3 capture d'écran: Samsung S3 screenshot

+0

http://stackoverflow.com/questions/22759358/wallpaper-not-properly-fit-on-device-screen –

+0

@IntelliJAmiya j'ai essayé ce code déjà mais encore un problème ...... une chose pouvez-vous m'expliquer pourquoi là ils utilisent le récepteur .... –

+0

@ Garg je pense qu'il y a un problème de taille de l'image avec vous.Veuillez vérifier la largeur et la hauteur de l'image et l'écran – PankajSharma

Répondre

0

-je résoudre ce problème à l'aide INTENTIONS d'appel à la place de WallpaperManager comme ceci:

// fichier de chargement

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."); 
} 
//

méthode pour obtenir chemin d'image

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