如何判断设备是否以编程方式使用TouchWiz

时间:2014-07-29 16:48:48

标签: android android-widget samsung-touchwiz

我需要在我的代码中检查我使用的设备是否启用了TouchWiz。我尝试使用

如果(android.os.Build.MANUFACTURER.equals(MANUFACTURER_SAMSUNG))

但事实证明有些设备是由三星制造的,不使用TouchWiz。

我怎么能弄清楚这一点?

2 个答案:

答案 0 :(得分:2)

检查默认启动器..我相信touchwiz是一个启动器

final Intent intent = new Intent(Intent.ACTION_MAIN); 
intent.addCategory(Intent.CATEGORY_HOME); 
final ResolveInfo res = getPackageManager().resolveActivity(intent, 0); 
if (res.activityInfo == null) {
    // should not happen. A home is always installed, isn't it?
} if ("android".equals(res.activityInfo.packageName)) {
    // No default selected     
} else {
     // res.activityInfo.packageName and res.activityInfo.name gives you the default app
} 

答案 1 :(得分:0)

您可以从PackageManager获取首选活动列表。使用getPreferredActivities()方法。

boolean isUsingTochwiz() {

    final IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN);
    filter.addCategory(Intent.CATEGORY_HOME);

    List<IntentFilter> filters = new ArrayList<IntentFilter>();
    filters.add(filter);

    final String myPackageName = "INSERT TOUCHWIZ PACKAGE NAME HERE";
    List<ComponentName> activities = new ArrayList<ComponentName>();
    final PackageManager packageManager = (PackageManager) getPackageManager();

    packageManager.getPreferredActivities(filters, activities, null);

    for (ComponentName activity : activities) {
        if (myPackageName.equals(activity.getPackageName())) {
            return true;
        }
    }
    return false;
}

取自:How to check if my application is the default launcher