android - 如何像普通应用程序一样在动态壁纸 Android 中添加应用程序图标

标签 android icons live wallpaper

是否可以添加一个应用程序图标,就像它在动态水族馆壁纸中显示的那样 (https://play.google.com/store/apps/details?id=fishnoodle.aquarium_free&feature=search_result#?t=W251bGwsMSwxLDEsImZpc2hub29kbGUuYXF1YXJpdW1fZnJlZSJd) 当我安装此墙纸时,它会显示和图标,单击它会打开设置页面。有没有人这样做过?

最佳答案

首先你应该创建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>

它创建图标,单击它会打开设置页面。 希望它能对您或其他人有所帮助。

关于android - 如何像普通应用程序一样在动态壁纸 Android 中添加应用程序图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10539579/

相关文章:

android - MainActivity 类型未定义方法 getActivity()

Android:工具栏文字颜色

ios - Apple HTTP Live Streaming 中的直播元数据读取

PHP mySql 更新在本地主机上运行良好,但在实时运行时运行不佳

android - SubscriptionManager 为运行 Android 5.1+ 的双 SIM 卡设备读取 IMSI

android - 以最小 API 14 (ICS) 为目标时,最好使用 FragmentActivity(或 ActionBarActivity)或系统 Activity?

android - NativeScript 8.0.4 Android 应用程序图标不会更改默认设置

android - Android中,字符串值和图形资源如何随主题切换?

c++ - 在可执行文件的资源中,如何找到默认图标?

iphone - Windows 上使用 FFmpeg 的多比特率实时 HLS