如何检测我的动态壁纸是在预览/"设置壁纸"活动中还是在主屏幕上运行



我只想在预览活动中从实时壁纸选择应用程序运行壁纸时绘制一条文本消息。(使用"设置壁纸"one_answers"设置"按钮)。

由于我将有一个免费和付费版本,在免费版本中,我也想让用户了解付费版本的功能,甚至在预览壁纸时启用这些功能,但不要在主屏幕上实际运行时启用,以免惹恼他们。

有什么想法吗?

作为一种选择,我可能会在壁纸第一次发布时显示这些信息,这些信息将始终来自预览活动。

在onCreateEngine()方法中使用isPreview()。

你会只检查你的壁纸是否已经设置好吗?

WallpaperService#onCreateEngine()的实现中,您可以执行以下操作:

WallpaperManager wpm = (WallpaperManager) getSystemService(WALLPAPER_SERVICE);
WallpaperInfo info = wpm.getWallpaperInfo();
if (info != null && info.getComponent().equals(new ComponentName(this, getClass()))) {
    Log.d(TAG, "We're already running");
    // Still might be a preview, but the user is already running your LWP.
} else {
    Log.d(TAG, "We're not running, this should be a preview");
    // Should definitely be a preview.
}

最新更新