Android 如何检测HTC Sense?

Android 如何检测HTC Sense?,android,android-ui,Android,Android Ui,我能检测到我的应用程序是否在HTC Sense上运行吗 更一般地说,问题是,我有一个自定义绘图按钮。它与Gmail应用程序右上角的账户切换程序非常相似。按下或对焦时,按钮具有橙色高亮显示。但这在HTC Sense上看起来不太好,因为标准的高亮颜色是绿色。让我们看看android.os.Build字符串我不确定HTC的人用什么组合来表示HTC Sense设备。我认为安卓为你提供了一个更好的方法来解决这个问题,而不是进行感官检查,它将适用于每个设备制造商。HTC并不是唯一一个改变选择器颜色的人。我认

我能检测到我的应用程序是否在HTC Sense上运行吗


更一般地说,问题是,我有一个自定义绘图按钮。它与Gmail应用程序右上角的账户切换程序非常相似。按下或对焦时,按钮具有橙色高亮显示。但这在HTC Sense上看起来不太好,因为标准的高亮颜色是绿色。

让我们看看android.os.Build字符串我不确定HTC的人用什么组合来表示HTC Sense设备。

我认为安卓为你提供了一个更好的方法来解决这个问题,而不是进行感官检查,它将适用于每个设备制造商。HTC并不是唯一一个改变选择器颜色的人。我认为索尼爱立信有一个透明的白色/蓝色,摩托罗拉在他们的MotoBlur用户界面中将其改为红色,而嘉敏华硕在他们的用户界面中将其改为蓝色只是举几个例子

您应该做的是覆盖图像按钮上的
android:background
属性,并使用自己的绘图工具,而不是依赖于框架的背景 可提取的。如果您还不熟悉它们,您可能还想在创建自定义背景时查看一下,这样您仍然可以看到按下/选择/未选择的颜色提示

如果有多个按钮要执行此操作,则可能需要使用样式和主题来帮助完成此操作。您希望从Android文档中引用的两个主要位置是“”和“”


希望有帮助

我认为应该遵循以下方法-我们定义
android:background
,类似

<?xml version="1.0" encoding="UTF-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@drawable/pressed_application_background" />
    <item android:state_focused="true" android:state_window_focused="true" android:drawable="@drawable/focused_application_background" />
    <item android:state_focused="true" android:state_window_focused="false" android:drawable="@android:color/transparent" />
</selector>

但是这里我们应该参考一些标准资源,而不是应用程序的图像。只需要找出他们有哪些ID。

这里有一个建议,可以在设备上检测HTC Sense,大约是讨论的三分之一。我测试了欲望和欲望Z

代码如下(来自用户:David):

private static final String SENSE\u UI\u LAUNCHER\u NAME=
“com.htc.launcher.launcher”;
私有静态布尔感官;
公共静态最终布尔值isSenseUI(上下文){
如果(感官==null){
感官=虚假;
PackageManager PackageManager=context.getPackageManager();
意向意向=新意向(意向.行动\主要);
intent.addCategory(intent.CATEGORY_HOME);
List List=packageManager.querytentActivities(
意图,PackageManager.MATCH_默认值(仅适用于);
用于(ResolveInfo:列表){
如果(info.activityInfo!=null
&&感知\u用户界面\u启动器\u名称
.equals(info.activityInfo.name)){
感官=真实;
打破
}
}
}
回归感官;
}

这有点晚了,但我认为这个解决方案可能适用于某些人的情况

我尝试使用Build.MANUFACTURER检查它是否是HTC设备。此解决方案在某些设备上不起作用,我们可以确保设备运行正常

如果您注意到,您可能会看到Play Store需要检查手机上的可用功能以显示正确的应用程序,而HTC Sense就是其中一个功能

要获取所有可用功能,请执行以下操作:

public FeatureInfo[] getSystemAvailableFeatures(Context context) {
        FeatureInfo[] features = context.getPackageManager().getSystemAvailableFeatures();
        for (FeatureInfo f : features) {
            Log.d("Features", "feature " + f.name);
        }
        return features;
}
这将返回如下内容:

com.example D/Features﹕ Feature android.hardware.wifi
com.example D/Features﹕ Feature android.hardware.location.network
com.example D/Features﹕ Feature com.sec.android.mdm
com.example D/Features﹕ Feature android.hardware.location
com.example D/Features﹕ Feature android.hardware.sensor.gyroscope
com.example D/Features﹕ Feature android.hardware.screen.landscape
com.example D/Features﹕ Feature com.htc.software.Sense5.0
注意最后一行!您可以使用它来检查HTC sense版本


希望它能帮上忙

在这个问题上,我是说我确实使用了定制的绘图工具。突出显示的颜色是橙色,在HTC的意义上看不出“原生”。在Android中没有简单的方法可以解决这个问题,因为每个制造商都有自己的UI风格…:(我所能做的就是检测我是否在Sense上并设置绿色的drawable。我知道除了Sense之外还有其他UI定制,但我只想处理Sense,因为它太普遍了。我使用的drawable不包括在Android中。
com.example D/Features﹕ Feature android.hardware.wifi
com.example D/Features﹕ Feature android.hardware.location.network
com.example D/Features﹕ Feature com.sec.android.mdm
com.example D/Features﹕ Feature android.hardware.location
com.example D/Features﹕ Feature android.hardware.sensor.gyroscope
com.example D/Features﹕ Feature android.hardware.screen.landscape
com.example D/Features﹕ Feature com.htc.software.Sense5.0