10

我能否以某种方式检测我的应用程序是否在 HTC Sense 上运行?

更一般地说,问题是,我有一个自定义可绘制按钮。它与 Gmail 应用右上角的帐户切换器非常相似。按下或聚焦时,该按钮具有橙色突出显示。但这在 HTC Sense 上看起来不太好——因为那里的标准高亮颜色是绿色。

4

5 回答 5

3

这是一个链接,建议在设备上检测 HTC Sense 的方法,大约是讨论的 1/3。我已经在 Desire 和 Desire Z 上进行了测试。

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

private static final String SENSE_UI_LAUNCHER_NAME = 
          "com.htc.launcher.Launcher"; 
    private static Boolean senseUI; 

    public static final boolean isSenseUI(Context context) {
        if (senseUI == null) {
            senseUI = false;
            PackageManager packageManager = context.getPackageManager();

            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_HOME);
            List<ResolveInfo> list = packageManager.queryIntentActivities(
                    intent, PackageManager.MATCH_DEFAULT_ONLY);
            for (ResolveInfo info : list) {
                if (info.activityInfo != null
                        && SENSE_UI_LAUNCHER_NAME
                                .equals(info.activityInfo.name)) {
                    senseUI = true;
                    break;
                }
            }
        }
        return senseUI;
    }
于 2011-06-28T09:56:20.643 回答
3

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

于 2010-09-09T13:34:32.343 回答
1

我认为 Android 为您提供了一种比检查 Sense 更好的方法来解决这个问题,并且它适用于每个设备制造商。HTC 并不是唯一改变选择器颜色的公司。我认为索尼爱立信有透明的白色/蓝色,摩托罗拉在他们的 MotoBlur UI 中将其更改为红色,而 Garmin-Asus 在他们的 UI 中将其更改为蓝色,仅举几例。

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

如果您有多个按钮要执行此操作,您可能需要使用样式和主题来帮助解决此问题。您需要从 Android 文档中引用的两个主要位置是“应用样式和主题”和“样式资源

希望有帮助!

于 2010-09-11T20:04:17.813 回答
0

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

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

如果您注意到,您可能会看到 Play 商店需要检查手机上有哪些可用功能才能显示正确的应用程序,而 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 版本

希望能帮助到你

于 2013-12-19T02:35:26.817 回答
0

我认为应该遵循以下方法-我们定义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。

于 2011-04-16T08:38:52.007 回答