Reputation: 2190
Is it possible to add an app icon , like it shows in Live Aquarium Wallpaper (https://play.google.com/store/apps/details?id=fishnoodle.aquarium_free&feature=search_result#?t=W251bGwsMSwxLDEsImZpc2hub29kbGUuYXF1YXJpdW1fZnJlZSJd) When I install this wallpaper, it shows and icon which opens up the settings page when clicked on it. Has anyone done this before?
Upvotes: 3
Views: 1159
Reputation: 3354
For those still looking for the correct answer:
You need to declare a <meta-data>
tag, inside your declaration of Wallpaper Service tag inside the manifest file:
<service
android:name=".MyWallpaperService"
android:enabled="true"
android:label="My Wallpaper"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService"/>
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/wallpaper" >
</meta-data>
</service>
This tag points to an xml file which contains information about the icon of the wallpaper which appears in the Live-Wallpapers section:
<?xml version="1.0" encoding="UTF-8"?>
<wallpaper
xmlns:android="http://schemas.android.com/apk/res/android"
android:label="GIF Wallpaper"
android:thumbnail="@android:drawable/btn_star">
</wallpaper>
So android:thumbnail
is where you set the resource for the icon
Upvotes: 0
Reputation: 7018
First of all you should create Activity
:
public class SetLiveWallpaperActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent();
if(Build.VERSION.SDK_INT >= 16)
{
intent.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName(this, LibGDXWallpaperService.class));
}
else
{
intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
}
startActivity(intent);
finish();
}
}
Then in your AndroidManifest.xml
you should add following code:
<activity
android:name=".SetLiveWallpaperActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light.WallpaperSettings" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
It creates icon which opens up the settings page when clicked on it. Hope it will help you or someone else.
Upvotes: 3
Reputation: 76458
You would need to declare an Activity in your AndroidManifest.xml
with the default intent-filter:
<activity
android:name="com.your.company.ui.SettingsActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 2