是否可以仅显示某个 android 版本的小部件? [英] is it possible to show widget only for a certain android version?

查看:18
本文介绍了是否可以仅显示某个 android 版本的小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在添加到主屏幕 > 小部件"对话框中仅针对某个 android 版本显示小部件,而无需上传两个 APK 并分配适当的 SDK 版本号?

is it possible to show widget in "Add to home screen > Widgets" Dialog only for a certain android version without uploading two APKs and assigning to proper SDK version numbers?

推荐答案

我有一种无需任何代码即可完成的方法,例如:

I have a way to do it without any code e.g.:

在您的 res\values 目录中创建一个 bools.xml 文件:

In your res\values dir create a bools.xml file:

创建一个 values-v11 目录(用于蜂窝或以上值),将文件复制到其中并将值设置为 true.

Create a values-v11 dir (for honeycomb or above values), copy the file to it and set the value to true.

然后在小部件接收器的清单中使用:android:enabled="@bool/honeycombOrAbove".我还在小部件的配置活动中使用了它.

Then in the manifest for the widget receiver use: android:enabled="@bool/honeycombOrAbove". I also used it in the configuration activity for the widget.

这意味着小部件在安装时被禁用.

This means the widget is disabled at install time.

这篇关于是否可以仅显示某个 android 版本的小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆