Pregunta

Necesito verificar desde mi código si el dispositivo que estoy usando tiene Touchwiz habilitado.Intenté usar

if (android.os.build.manufacturer.equals (fabricante_samsung))

Pero resulta que algunos dispositivos son hechos por Samsung y no usan Touchwiz.

¿Cómo puedo resolver esto?

¿Fue útil?

Solución

Revise el iniciador predeterminado. Creo que TouchWiz es un lanzador

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
} 

Otros consejos

Puede obtener la lista de actividades preferidas de Packagemanager.Utilice getPreferredactivities () Método.

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;
}

Tomado de: Cómo comprobar si mi solicitudes el iniciador predeterminado

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top