当前位置: 首页>>代码示例>>Java>>正文


Java ComponentName.unflattenFromString方法代码示例

本文整理汇总了Java中android.content.ComponentName.unflattenFromString方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentName.unflattenFromString方法的具体用法?Java ComponentName.unflattenFromString怎么用?Java ComponentName.unflattenFromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ComponentName的用法示例。


在下文中一共展示了ComponentName.unflattenFromString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAccessibilityServiceEnabled

import android.content.ComponentName; //导入方法依赖的package包/类
public static boolean isAccessibilityServiceEnabled(Context context, Class<? extends AccessibilityService> accessibilityService) {
    ComponentName expectedComponentName = new ComponentName(context, accessibilityService);

    String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
    if (enabledServicesSetting == null)
        return false;

    TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
    colonSplitter.setString(enabledServicesSetting);

    while (colonSplitter.hasNext()) {
        String componentNameString = colonSplitter.next();
        ComponentName enabledService = ComponentName.unflattenFromString(componentNameString);

        if (enabledService != null && enabledService.equals(expectedComponentName))
            return true;
    }

    return false;
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:21,代码来源:AccessibilityServiceUtils.java

示例2: getRuleInfo

import android.content.ComponentName; //导入方法依赖的package包/类
public static RuleInfo getRuleInfo(ServiceInfo si) {
    if (si == null || si.metaData == null) return null;
    final String ruleType = si.metaData.getString(MD_RULE_TYPE);
    final String defaultConditionId = si.metaData.getString(MD_DEFAULT_CONDITION_ID);
    final String configurationActivity = si.metaData.getString(MD_CONFIGURATION_ACTIVITY);
    if (ruleType != null && !ruleType.trim().isEmpty() && defaultConditionId != null) {
        final RuleInfo ri = new RuleInfo();
        ri.serviceComponent = new ComponentName(si.packageName, si.name);
        ri.settingsAction = ZenModeExternalRuleSettings.ACTION;
        ri.caption = ruleType;
        ri.defaultConditionId = Uri.parse(defaultConditionId);
        if (configurationActivity != null) {
            ri.configurationActivity = ComponentName.unflattenFromString(configurationActivity);
        }
        return ri;
    }
    return null;
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:19,代码来源:ZenModeExternalRuleSettings.java

示例3: ComponentKey

import android.content.ComponentName; //导入方法依赖的package包/类
/**
 * Creates a new component key from an encoded component key string in the form of
 * [flattenedComponentString#userId].  If the userId is not present, then it defaults
 * to the current user.
 */
public ComponentKey(Context context, String componentKeyStr) {
    int userDelimiterIndex = componentKeyStr.indexOf("#");
    if (userDelimiterIndex != -1) {
        String componentStr = componentKeyStr.substring(0, userDelimiterIndex);
        Long componentUser = Long.valueOf(componentKeyStr.substring(userDelimiterIndex + 1));
        componentName = ComponentName.unflattenFromString(componentStr);
        user = UserManagerCompat.getInstance(context)
                .getUserForSerialNumber(componentUser.longValue());
    } else {
        // No user provided, default to the current user
        componentName = ComponentName.unflattenFromString(componentKeyStr);
        user = Process.myUserHandle();
    }
    mHashCode = Arrays.hashCode(new Object[] {componentName, user});
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:21,代码来源:ComponentKey.java

示例4: rewriteNumber

import android.content.ComponentName; //导入方法依赖的package包/类
/**
 * Rewrite a number using a given plugin.
 * Warning this should never be done on main thread otherwise will always fail due to thread issues.
 * 
 * @param context The application context to use to talk to plugin
 * @param componentName The fully qualified component name of the plugin
 * @param number The number to rewrite
 */
public static String rewriteNumber(Context context, final String componentName, String number) {
    ComponentName cn = ComponentName.unflattenFromString(componentName);

    Intent it = new Intent(SipManager.ACTION_REWRITE_NUMBER);
    it.putExtra(Intent.EXTRA_PHONE_NUMBER, number);
    it.setComponent(cn);
    
    OnRewriteReceiver resultTreater = new OnRewriteReceiver(number);
    context.sendOrderedBroadcast(it, permission.PROCESS_OUTGOING_CALLS, resultTreater, null,
            Activity.RESULT_OK, null, null);
    
    return resultTreater.getResult();
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:22,代码来源:RewriterPlugin.java

示例5: getLabel

import android.content.ComponentName; //导入方法依赖的package包/类
public static Pair<String, String> getLabel(Context context, String comboAsString) {
    String recognizer = "[?]";
    String language = "[?]";
    String[] splits = TextUtils.split(comboAsString, SEPARATOR);
    if (splits.length > 0) {
        PackageManager pm = context.getPackageManager();
        ComponentName recognizerComponentName = ComponentName.unflattenFromString(splits[0]);
        if (recognizerComponentName != null) {
            try {
                ServiceInfo si = pm.getServiceInfo(recognizerComponentName, 0);
                recognizer = si.loadLabel(pm).toString();
            } catch (PackageManager.NameNotFoundException e) {
                // ignored
            }
        }
    }
    if (splits.length > 1) {
        language = makeLangLabel(splits[1]);
    }
    return new Pair<>(recognizer, language);
}
 
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:22,代码来源:RecognitionServiceManager.java

示例6: readChild

import android.content.ComponentName; //导入方法依赖的package包/类
@Override
protected void readChild(XmlPullParser parser) throws IOException, XmlPullParserException {
    String currentTag = parser.getName();

    if (currentTag.equals(TAG_INTENT_FILTER)) {
        FirewallIntentFilter intentFilter = new FirewallIntentFilter(this);
        intentFilter.readFromXml(parser);
        mIntentFilters.add(intentFilter);
    } else if (currentTag.equals(TAG_COMPONENT_FILTER)) {
        String componentStr = parser.getAttributeValue(null, ATTR_NAME);
        if (componentStr == null) {
            throw new XmlPullParserException("Component name must be specified.",
                    parser, null);
        }

        ComponentName componentName = ComponentName.unflattenFromString(componentStr);
        if (componentName == null) {
            throw new XmlPullParserException("Invalid component name: " + componentStr);
        }

        mComponentFilters.add(componentName);
    } else {
        super.readChild(parser);
    }
}
 
开发者ID:TaRGroup,项目名称:IFWManager,代码行数:26,代码来源:IntentFirewall.java

示例7: ComponentKey

import android.content.ComponentName; //导入方法依赖的package包/类
/**
 * Creates a new component key from an encoded component key string in the form of
 * [flattenedComponentString#userId].  If the userId is not present, then it defaults
 * to the current user.
 */
public ComponentKey(Context context, String componentKeyStr) {
    int userDelimiterIndex = componentKeyStr.indexOf("#");
    if (userDelimiterIndex != -1) {
        String componentStr = componentKeyStr.substring(0, userDelimiterIndex);
        Long componentUser = Long.valueOf(componentKeyStr.substring(userDelimiterIndex + 1));
        componentName = ComponentName.unflattenFromString(componentStr);
        user = UserManagerCompat.getInstance(context)
                .getUserForSerialNumber(componentUser.longValue());
    } else {
        // No user provided, default to the current user
        componentName = ComponentName.unflattenFromString(componentKeyStr);
        user = UserHandleCompat.myUserHandle();
    }
    Preconditions.assertNotNull(componentName);
    Preconditions.assertNotNull(user);
    mHashCode = Arrays.hashCode(new Object[] {componentName, user});
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:23,代码来源:ComponentKey.java

示例8: isNotificationServiceEnabled

import android.content.ComponentName; //导入方法依赖的package包/类
private boolean isNotificationServiceEnabled(){
    String pkgName = getPackageName();
    final String flat = Settings.Secure.getString(getContentResolver(),
            ENABLED_NOTIFICATION_LISTENERS);
    if (!TextUtils.isEmpty(flat)) {
        final String[] names = flat.split(":");
        for (int i = 0; i < names.length; i++) {
            final ComponentName cn = ComponentName.unflattenFromString(names[i]);
            if (cn != null) {
                if (TextUtils.equals(pkgName, cn.getPackageName())) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:mcosti,项目名称:notifications-forwarder,代码行数:18,代码来源:WelcomeActivity.java

示例9: isNotificationListenerEnabled

import android.content.ComponentName; //导入方法依赖的package包/类
private Boolean isNotificationListenerEnabled()
{
    String listenerString = Settings.Secure.getString(getContentResolver(), "enabled_notification_listeners");

    if (listenerString != null && !listenerString.equals(""))
    {
        String[] listeners = listenerString.split(":");
        for (String listener : listeners)
        {
            ComponentName componentName = ComponentName.unflattenFromString(listener);
            if (componentName != null)
                if (componentName.getPackageName().equals(getPackageName()))
                    return true;
        }
    }
    return false;
}
 
开发者ID:MihaiBojescu,项目名称:Linux-notifier-Android,代码行数:18,代码来源:MainActivity.java

示例10: getEnabledListenerPackages

import android.content.ComponentName; //导入方法依赖的package包/类
public static Set<String> getEnabledListenerPackages(Context context) {
    String enabledNotificationListeners = Secure.getString(context.getContentResolver(), SETTING_ENABLED_NOTIFICATION_LISTENERS);
    if (!(enabledNotificationListeners == null || enabledNotificationListeners.equals(sEnabledNotificationListeners))) {
        String[] components = enabledNotificationListeners.split(":");
        Set<String> packageNames = new HashSet(components.length);
        for (String component : components) {
            ComponentName componentName = ComponentName.unflattenFromString(component);
            if (componentName != null) {
                packageNames.add(componentName.getPackageName());
            }
        }
        synchronized (sEnabledNotificationListenersLock) {
            sEnabledNotificationListenerPackages = packageNames;
            sEnabledNotificationListeners = enabledNotificationListeners;
        }
    }
    return sEnabledNotificationListenerPackages;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:NotificationManagerCompat.java

示例11: loadEnabledServices

import android.content.ComponentName; //导入方法依赖的package包/类
private void loadEnabledServices() {
    mEnabledServices.clear();
    final String flat = Settings.Secure.getString(mContentResolver, mConfig.setting);
    if (flat != null && !"".equals(flat)) {
        final String[] names = flat.split(":");
        for (int i = 0; i < names.length; i++) {
            final ComponentName cn = ComponentName.unflattenFromString(names[i]);
            if (cn != null) {
                mEnabledServices.add(cn);
            }
        }
    }
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:14,代码来源:ServiceListing.java

示例12: isAccessibilityServiceEnabled

import android.content.ComponentName; //导入方法依赖的package包/类
public static boolean isAccessibilityServiceEnabled(Context context, Class<? extends AccessibilityService> accessibilityService) {
    String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
    if (enabledServicesSetting == null) return false;
    TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
    colonSplitter.setString(enabledServicesSetting);
    while (colonSplitter.hasNext()) {
        ComponentName enabledService = ComponentName.unflattenFromString(colonSplitter.next());
        if (enabledService != null && enabledService.equals(new ComponentName(context, accessibilityService)))
            return true;
    }
    return false;
}
 
开发者ID:Omico,项目名称:CurrentActivity,代码行数:13,代码来源:AccessibilityServiceUtils.java

示例13: Theme

import android.content.ComponentName; //导入方法依赖的package包/类
public Theme(Context ctxt, String packageName) {
	pm = ctxt.getPackageManager();
	
	ComponentName cn = ComponentName.unflattenFromString(packageName);
	
	try {
           pInfos = pm.getPackageInfo(cn.getPackageName(), 0);
           remoteRes = pm.getResourcesForApplication(cn.getPackageName());
       } catch (NameNotFoundException e) {
           Log.e(THIS_FILE, "Impossible to get resources from " + cn.toShortString());
           remoteRes = null;
           pInfos = null;
       }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:15,代码来源:Theme.java

示例14: loadEnabledServices

import android.content.ComponentName; //导入方法依赖的package包/类
private HashSet<ComponentName> loadEnabledServices() {
    HashSet<ComponentName> hashSet = new HashSet();
    String string = Settings.Secure.getString(getContentResolver()
            , "enabled_notification_listeners");
    if (!(string == null || "".equals(string))) {
        String[] split = string.split(":");
        for (String unflattenFromString : split) {
            ComponentName unflattenFromString2 = ComponentName.unflattenFromString(unflattenFromString);
            if (unflattenFromString2 != null) {
                hashSet.add(unflattenFromString2);
            }
        }
    }
    return hashSet;
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:16,代码来源:XmsfApp.java

示例15: isNotificationListenEnable

import android.content.ComponentName; //导入方法依赖的package包/类
public static boolean isNotificationListenEnable(Context context, String pkgName) {
    final String flat = Settings.Secure.getString(context.getContentResolver(), ENABLED_NOTIFICATION_LISTENERS);
    if (!TextUtils.isEmpty(flat)) {
        final String[] names = flat.split(":");
        for (int i = 0; i < names.length; i++) {
            final ComponentName cn = ComponentName.unflattenFromString(names[i]);
            if (cn != null) {
                if (TextUtils.equals(pkgName, cn.getPackageName())) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:16,代码来源:NotificationService.java


注:本文中的android.content.ComponentName.unflattenFromString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。