android 修改 选择壁纸来源,修改android选择壁纸来源列表

在主界面按菜单键会弹出菜单,其中有一项是壁纸,当选择之后,出现一个选择器,出现一个列表,这个不是dialog ,你可以选择是一般的壁纸,还是比较炫的动态壁纸或者是从设备中寻找存在的照片设置为你的桌面壁纸。startWallpaper 方法,看一下源码

private void startWallpaper() {

closeAllApps(true);

final Intent pickWallpaper = new Intent(Intent.ACTION_SET_WALLPAPER);

Intent chooser = Intent.createChooser(pickWallpaper,

getText(R.string.chooser_wallpaper));

// NOTE: Adds a configure option to the chooser if the wallpaper supports it

// Removed in Eclair MR1

// WallpaperManager wm = (WallpaperManager)

// getSystemService(Context.WALLPAPER_SERVICE);

// WallpaperInfo wi = wm.getWallpaperInfo();

// if (wi != null && wi.getSettingsActivity() != null) {

// LabeledIntent li = new LabeledIntent(getPackageName(),

// R.string.configure_wallpaper, 0);

// li.setClassName(wi.getPackageName(), wi.getSettingsActivity());

// chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { li });

// }

startActivityForResult(chooser, REQUEST_PICK_WALLPAPER);

}

其实是根据 Intent 调用相关的 Activity。

final Intent pickWallpaper = new Intent(Intent.ACTION_SET_WALLPAPER);

Intent chooser = Intent.createChooser(pickWallpaper,

getText(R.string.chooser_wallpaper));

Intent.ACTION_SET_WALLPAPER 表示的含义以及它的真实值 查看api

public static final String ACTION_SET_WALLPAPER

Since: API Level 1

Activity Action: Show settings for choosing wallpaper

Input: Nothing.

Output: Nothing.

Constant Value: "android.intent.action.SET_WALLPAPER"

该 Intent 常量是一个 String,表示启用设置壁纸的 Activity,也就是说只要我们的系统中有这样的 Activity(action 为 android.intent.action.SET_WALLPAPER)就可以出现在选择器中。

原生的 android 系统中有三个这样的 Activity

1.WallpaperChooser.java

这是 Launcher 中的一个类,主要是选择壁纸的操作,和 Launcher.java 在一个包下面。通过 Launcher 的 Manifest.xml 文件就可以看到答案

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值