1

I want to get the home wallpaper set and put it as my background for my activity. Is this possible ?

I searched on the internet with

WallpaperInfo v = w.getWallpaperInfo();
String name = v.getServiceName();

I have the service name (because the wallpaper is a live service) for example, I have com.android.wallpaper.grass.GrassWallpaper...can I use this to start service into my activity?

If so, how?

Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
Mimmo
  • 37
  • 1
  • 3

3 Answers3

8

Try to add this attribute to your tag in the manifest:

android:theme="@android:style/Theme.Wallpaper"

Panshul
  • 956
  • 1
  • 10
  • 25
4

It seems you even haven't tried to do anything... whatever, you can get the wallpaper by doing:

WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable wallpaperDrawable = wallpaperManager.getDrawable();

Then, you can use that drawable and set it as the background of your activity.

Cristian
  • 198,401
  • 62
  • 356
  • 264
  • Honestly, I don't know whether that's possible. Try to see if the `getWallpaperInfo()` gives you enough information to extract the wallpaper. – Cristian Feb 12 '11 at 23:57
0

using WalpaperManager requires storage permition. so I suggest this amazing way:

if your main theme name is AppTheme, some thing like this:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

then create another theme named AppTheme.Wallpaper:

<style name="AppTheme.Wallpaper" parent="AppTheme">
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:colorBackgroundCacheHint">@null</item>
  <item name="android:windowShowWallpaper">true</item>
</style>

then put that theme in the manifest as your activity attribute:

<activity android:name=".YOUR_ACTIVITY"
    
android:theme="@style/AppTheme.Wallpaper">

</activity>
Amir Hossein
  • 392
  • 3
  • 11