1.6 Android 应用程序上的动态壁纸

发布于 2024-08-27 02:01:45 字数 504 浏览 10 评论 0原文

我有一个版本为 1.6 的 Android 应用程序 我拍摄壁纸并将其显示在我的应用程序上。 (我通过在 Activity 上调用 getWallpaper() 以编程方式执行此操作)

当将其安装在具有动态壁纸的 2.1 手机上时, getWallpaper() 不会返回动态壁纸,因为它只返回一个 Drawable,并且动态壁纸可能是另一回事。

那么问题来了,是否可以在1.6应用程序的背景上显示动态壁纸呢?如何?

谢谢

=================================================== =========================================

到目前为止我还没有找到解决方案。 我添加此内容是为了更好地理解这个问题

。需要明确的是:该应用程序是为 1.6 编写的,因此它可以在所有 1.6 及更高版本上运行。问题是:我们是否可以编写一个以 1.6 为目标,但在 2.1 设备上运行时支持动态壁纸的应用程序?

谢谢

I have an Android application with version 1.6
I take the wallpaper and show it on my application.
(I do that programatically by calling getWallpaper() on the Activity)

When this is installed on a 2.1 phone, that has live wallpaper, the live wallpaper is not returned by getWallpaper() , because it just returns a Drawable, and live wallpaper probably is another thing.

So the question is, is it possible to show a live wallpaper on the background of a 1.6 application? How?

Thanks

========================================================================================

So far I haven't found a solution for this.
I am adding this to better understand the question

To be clear: The app is written for 1.6 so it will work on all 1.6 and higher. The question is: can we write an app with 1.6 as the target, but support live wallpapers if its being run on a 2.1 device??

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

宣告ˉ结束 2024-09-03 02:01:45

我找到了一个解决方案:

1)使用 android.os.Build.VERSION.SDK_INT 检查手机的版本。
2) 进行 if/else 调用,因此对于每个版本,您都可以调用所需的方法。
在这种情况下:

如果(android.os.Build.VERSION.SDK_INT >= 7){

this.setTheme(android.R.style.Theme_Wallpaper);

}

其他

{

//别的东西

}

3) 使用 2.1 构建应用程序。并在清单中设置uses-sdk android:minSdkVersion =“4”,以便它也可以在1.6上运行

4)确保它可以在手机1.6和2.1上运行,因为既然您调用了这两个SDK,请确保您不调用以下方法当您运行 1.6 时为 2.1,反之亦然。

感谢您的帮助

I found a solution:

1) With android.os.Build.VERSION.SDK_INT check what version the phone has.
2) make if/else calls, so for each version you can call the desired method.
In this case:

if (android.os.Build.VERSION.SDK_INT >= 7) {

this.setTheme(android.R.style.Theme_Wallpaper);

}

else

{

//something else

}

3) Build the app using 2.1. and set in the manifest uses-sdk android:minSdkVersion="4" so it also runs on 1.6

4) make sure it works on both phones 1.6 and 2.1, because since you have calls to both SDKs, make sure you dont call methods of 2.1 when you are running 1.6 and the other way around.

Thanks for the help

吻泪 2024-09-03 02:01:45

动态壁纸是在 2.1 中添加的,因此尝试在 1.6(或 2.0)设备上显示动态壁纸根本没有意义。

在 2.0 中添加了 Theme.Wallpaper 主题样式,这是将活动(或窗口)置于系统壁纸(实时或非实时)之上的新官方方式。当然,由于这个是2.0中出现的,所以在1.6中你也不能使用这个。

在 2.0 之前,在系统壁纸之上显示的唯一方法是使用 getWallpaper() 检索静态壁纸图像,并自行在 UI 中绘制它。这当然不能支持动态壁纸。

如果您想要一个应用程序在 2.0 之前和 2.0 以及更高版本的平台上都显示在壁纸中,您将需要检查 android.os.Build 中的 API 版本,并适当调整您的行为:在初始化您的应用程序时Activity,如果2.0或更高版本使用setTheme来选择壁纸主题;否则,获取可绘制对象并将其设为 UI 的背景。使用壁纸主题时,您需要确保您的 UI 不会在其上方绘制不透明背景并将其覆盖。您可能还想尝试将 Activity 的主题设置为 Theme.Translucent,以便在 2.0 或更高版本上获得更好的行为(理想情况下您将使用 Theme.Wallpaper,它也可以为您提供适当的动画)。

实际上,您可以想象使用版本化资源来制作自己的主题,根据平台版本(壁纸或传统主题)进行适当调整。不过,我从未尝试过这样做。

Live wallpapers were added in 2.1, so it simply does not make sense to try to show a live wallpaper on a 1.6 (or 2.0) device.

In 2.0 the Theme.Wallpaper theme style was added, which as the new official way to put an activity (or window) on top of the system's wallpaper (live or not). Of course, since this appeared in 2.0, you also can not use this in 1.6.

Prior to 2.0, the only way to display on top of the system wallpaper was to use getWallpaper() to retrieve the static wallpaper image, and take care of drawing it yourself in your UI. This of course can not support live wallpapers.

If you want to have an app that shows in the wallpaper on both pre-2.0 and 2.0 and later versions of the platform, you will need to check the API version in android.os.Build, and adjust your behavior appropriately: when initializing your activity, if 2.0 or later use setTheme to choose the wallpaper theme; otherwise, get the drawable and make it the background of your UI. When using the wallpaper theme, you need to make sure your UI does not draw an opaque background on top of it and cover it up. You may also want to try setting your activity's theme to Theme.Translucent, to get better behavior on 2.0 or later (where ideally you would use Theme.Wallpaper which also gives you the proper animations).

Actually, you could conceivable use versioned resouurces to make your own theme that adjusts appropriately depending on the platform version (either a wallpaper or a traditional theme). I have never tried to do this, though.

她比我温柔 2024-09-03 02:01:45

您是否尝试过使用 Theme.Wallpaper 作为 Activity 的主题?这会将手机壁纸设置为活动背景,并与动态壁纸配合使用。

Have you tried using Theme.Wallpaper as your Activity's theme? That sets the phone's wallpaper as the background of the activity, and works with Live Wallpapers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文