让活动出现在'壁纸选择器'中

时间:2010-09-25 06:29:04

标签: android android-intent

我希望我的活动显示在您尝试从主屏幕选择壁纸时看到的活动列表(图库。动态壁纸等)。

我假设这是用意图完成的,但似乎找不到有效的方法。我能找到的最接近的是:

<action android:name="android.intent.action.ACTION_SET_WALLPAPER>

但这不起作用,似乎用于别的东西。

3 个答案:

答案 0 :(得分:13)

这应该是您想要的intent-filter:

<intent-filter>
    <action android:name="android.intent.action.SET_WALLPAPER" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

在此定义:http://developer.android.com/reference/android/content/Intent.html#ACTION_SET_WALLPAPER

(DEFAULT类别是意图的标准语法。)

答案 1 :(得分:1)

当您从主屏幕点击“壁纸”时弹出的“选择壁纸”对话框下的列表在大多数手机上都有三个条目(我检查了股票和HTC Sense):

  • 动态壁纸
  • 壁纸(或:HTC壁纸)

当我在HTC Sense的主屏幕上按“壁纸”时,我得到:

09-26 20:17:58.901: INFO/ActivityManager(104): Starting activity: Intent { act=android.intent.action.SET_WALLPAPER_DIALOG cmp=com.htc.launcher/.WallpaperChooserDialog (has extras) }
09-26 20:17:59.301: INFO/ActivityManager(104): Displayed activity com.htc.launcher/.WallpaperChooserDialog: 353 ms (total 353 ms)

库存时:

09-26 20:19:41.231: INFO/ActivityManager(86): Starting activity: Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras) }
09-26 20:19:41.571: INFO/ActivityManager(86): Displayed activity android/com.android.internal.app.ChooserActivity: 294 ms (total 294 ms)

当我在库存时点击“壁纸”时:

09-26 20:19:51.101: INFO/ActivityManager(86): Starting activity: Intent { act=android.intent.action.SET_WALLPAPER flg=0x3000000 cmp=com.android.launcher/com.android.launcher2.WallpaperChooser }
09-26 20:19:51.581: INFO/ActivityManager(86): Displayed activity com.android.launcher/com.android.launcher2.WallpaperChooser: 463 ms (total 463 ms)

您需要使用android.intent.action.SET_WALLPAPER。也许你忘了其他一些实现细节,比如

<category android:name="android.intent.category.DEFAULT" /> 

所以选择者可以拿起它?看看Photostream的源代码(http://code.google.com/p/apps-for-android/source/browse/trunk/#trunk/Photostream)。 Romain Guy让它发挥作用。

答案 2 :(得分:0)

基本上,您无法将活动设置为壁纸。您必须改为创建Live Wallpaper,并使用SurfaceViewCanvas上绘制内容。您可以在那里自己创建视图,以便手动在画布上绘制它们,但这有点棘手,在大多数情况下不是您想要的。