是否可以添加一个应用程序图标,就像它在动态水族馆壁纸中显示的那样 (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/