launcher 3は壁紙をデスクトップの壁紙リストに追加します。
本文を書く前に、まずLauncher 3デスクトップの壁紙を詳しく紹介するブログを紹介します。ブログのリンクはLauncher 3ーー壁紙です。http://blog.csdn.net/dingfengnupt88/article/details/51833046
この論文ではlauncher 3による修正壁紙の原理について詳しく説明しないで、直接に一つの方法を提供して、お気に入りの画像をデスクトップの壁紙リストに追加します。
この方法は、Wallpaper PickerActivityにおけるfindBuldWallpapers法で実行でき、これにより、自分の欲しい画像を壁紙リストに追加することができる。
コードによってデスクトップのデフォルトの壁紙を変更したり、デスクトップの壁紙を削除したりします。おすすめのブログをよく読んでください。中にはlauncher 3の壁紙が詳しく紹介されています。
この論文ではlauncher 3による修正壁紙の原理について詳しく説明しないで、直接に一つの方法を提供して、お気に入りの画像をデスクトップの壁紙リストに追加します。
/**
*
*
* @param wallpaperPath
*/
private void addMyWallpaper(String wallpaperPath, ArrayList bundled) {
try {
File mWallpaperDir = new File(wallpaperPath);
if (mWallpaperDir.exists()) {
if (mWallpaperDir.isDirectory()) {
File[] files = mWallpaperDir.listFiles();
for (File file : files) {
if (!file.isFile()) {
continue;
}
String name = file.getName();
int dotPos = name.lastIndexOf('.');
String extension = "";
if (dotPos >= -1) {
extension = name.substring(dotPos);
name = name.substring(0, dotPos);
}
if (!extension.endsWith("png") && !extension.endsWith("jpg")) {
// if (!extension.endsWith("jpg")) {
// PNG , ,JPG
continue;
}
File thumbnail = new File(mWallpaperDir, name + extension);
String absolutePath = thumbnail.getAbsolutePath();
Log.d(TAG, "wallpaper file path name: " + absolutePath);
// Bitmap myThumbnail = createMyThumbnail(this, thumbnail.getAbsolutePath(), 0, false);
Bitmap myThumbnail = BitmapFactory.decodeFile(thumbnail.getAbsolutePath());
bundled.add(new FileWallpaperInfo(thumbnail, new BitmapDrawable(myThumbnail)));
}
}
} else
Log.e(TAG, "File path " + wallpaperPath + " not exists");
}catch (Throwable throwable){
throwable.printStackTrace();
}
}
上記の方法は、ターゲットフォルダをスキャンして、フォルダ内の画像を壁紙リストに追加することです。この方法は、Wallpaper PickerActivityにおけるfindBuldWallpapers法で実行でき、これにより、自分の欲しい画像を壁紙リストに追加することができる。
コードによってデスクトップのデフォルトの壁紙を変更したり、デスクトップの壁紙を削除したりします。おすすめのブログをよく読んでください。中にはlauncher 3の壁紙が詳しく紹介されています。