How to add an application icon to Live Wallpaper Android, like regular applications

Is it possible to add an application icon, for example, in Live Aquarium Wallpaper (https://play.google.com/store/apps/details?id=fishnoodle.aquarium_free&feature=search_result#?t=W251bGwsMSwxLDEsImZpc2hub29kbGUuYXF1YXJpdW1SJZZdl1 which displays this) and an icon that opens the settings page when you click on it. Has anyone done this before?

+3
source share
3 answers

You will need to declare an action in yours AndroidManifest.xmlusing the 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>
+2
source

First of all, you must 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();
  } 
}

AndroidManifest.xml :

 <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>

, . , - .

+3

For those who are still looking for the right answer:

You need to declare the tag <meta-data>inside the declaration of the wallpaper browser ad 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 that contains information about the wallpaper icon that appears in the Live Wallpaper 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:thumbnailthis is the place where you set the resource for the icon

0
source

All Articles