Domanda

Ho bisogno di controllare all'interno del mio codice se il dispositivo che sto usando ha touchwiz abilitato.Ho provato a usare

IF (Android.os.Build.Manufacturer.equals (Produttore_Samsung))

Ma risulta che alcuni dispositivi vengono effettuati da Samsung e non usare touchwiz.

Come posso capirlo?

È stato utile?

Soluzione

Controllare il lancio predefinito .. Io credo che TouchWiz sia un lanciatore

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

Altri suggerimenti

È possibile ottenere l'elenco delle attività preferite da PackageManager.Usa il metodo GetPreferRerattività ().

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

Tratto da: Come controllare se la mia applicazioneè il lanciatore predefinito

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top