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


Java ComponentName.equals方法代码示例

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


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

示例1: checkIfServiceIsRunning

import android.content.ComponentName; //导入方法依赖的package包/类
public static boolean checkIfServiceIsRunning(Context context, Class<?> service) {

        String serviceName = service.getName();

        ComponentName componentName = new ComponentName(context.getPackageName(), serviceName);

        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

        List<ActivityManager.RunningServiceInfo> procList = activityManager.getRunningServices(Integer.MAX_VALUE);

        if (procList != null) {

            for (ActivityManager.RunningServiceInfo appProcInfo : procList) {
                if (appProcInfo != null && componentName.equals(appProcInfo.service)) {
                    log.d("%s is already running", serviceName);
                    return true;
                }
            }
        }
        log.d("%s is not running", serviceName);
        return false;
    }
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:ServiceHelper.java

示例2: isRecognitionServiceInstalled

import android.content.ComponentName; //导入方法依赖的package包/类
/**
 * @return true iff a RecognitionService with the given component name is installed
 */
public static boolean isRecognitionServiceInstalled(PackageManager pm, ComponentName componentName) {
    List<ResolveInfo> services = pm.queryIntentServices(
            new Intent(RecognitionService.SERVICE_INTERFACE), 0);
    for (ResolveInfo ri : services) {
        ServiceInfo si = ri.serviceInfo;
        if (si == null) {
            Log.i("serviceInfo == null");
            continue;
        }
        if (componentName.equals(new ComponentName(si.packageName, si.name))) {
            return true;
        }
    }
    return false;
}
 
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:19,代码来源:RecognitionServiceManager.java

示例3: 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

示例4: getPssForService

import android.content.ComponentName; //导入方法依赖的package包/类
/**
 * Get the PSS used by the process hosting a service.
 *
 * @param packageName Package name of the service to search for.
 * @return the PSS in kB of the process hosting a service, or INVALID_PSS.
 */
@VisibleForTesting
static int getPssForService(ComponentName componentName) {
    if (componentName == null) return INVALID_PSS;
    Context context = ContextUtils.getApplicationContext();
    ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> services =
            activityManager.getRunningServices(1000);
    if (services == null) return INVALID_PSS;
    int pid = -1;
    for (ActivityManager.RunningServiceInfo info : services) {
        if (componentName.equals(info.service)) {
            pid = info.pid;
            break;
        }
    }
    if (pid == -1) return INVALID_PSS;
    Debug.MemoryInfo infos[] = activityManager.getProcessMemoryInfo(new int[] {pid});
    if (infos == null || infos.length == 0) return INVALID_PSS;
    return infos[0].getTotalPss();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:28,代码来源:GSAServiceClient.java

示例5: addLink

import android.content.ComponentName; //导入方法依赖的package包/类
private void addLink(Context context, String label, Uri uri, ComponentName cn, Bitmap bitmap) {
    DB db = GlobState.getGlobState(context).getDB();

    ComponentName latest = db.getLatestInstall();
    if (latest!=null && System.currentTimeMillis() - db.getLatestInstallTime()<4000) {
        if (latest.equals(cn)) {
            Log.i("ShortcutCatch", "ignoring cn2package=" + cn.getPackageName() + ", cn2classname=" + cn.getClassName());
            return;
        }
    }

    String catID = Categories.getCategoryForComponent(context, cn, true);

    AppLauncher appLauncher = AppLauncher.createActionLink(cn.getClassName(), uri, cn.getPackageName(),label, catID);
    db.addApp(appLauncher);

    if (bitmap!=null) {
        SpecialIconStore.saveBitmap(context, appLauncher.getComponentName(), bitmap, SpecialIconStore.IconType.Shortcut);
    }

}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:22,代码来源:ShortcutReceiver.java

示例6: findService

import android.content.ComponentName; //导入方法依赖的package包/类
public static ServiceInfo findService(Context context, Config config, final ComponentName cn) {
    final ServiceListing listing = new ServiceListing(context, config);
    final List<ServiceInfo> services = listing.reload();
    for (ServiceInfo service : services) {
        final ComponentName serviceCN = new ComponentName(service.packageName, service.name);
        if (serviceCN.equals(cn)) {
            return service;
        }
    }
    return null;
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:12,代码来源:ServiceListing.java

示例7: 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

示例8: removeFromQuickApps

import android.content.ComponentName; //导入方法依赖的package包/类
public void removeFromQuickApps(ComponentName actvname) {
    for (int i = mQuickRow.getChildCount()-1; i>=0; i--) {
        AppLauncher app = (AppLauncher) mQuickRow.getChildAt(i).getTag();
        if (app != null && actvname.equals(app.getComponentName())) {
            mQuickRow.removeView(mQuickRow.getChildAt(i));
        }
    }
}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:9,代码来源:QuickRow.java

示例9: getItemInfoForComponentName

import android.content.ComponentName; //导入方法依赖的package包/类
@Thunk ArrayList<ItemInfo> getItemInfoForComponentName(final ComponentName cname,
        final UserHandleCompat user) {
    ItemInfoFilter filter  = new ItemInfoFilter() {
        @Override
        public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {
            if (info.user == null) {
                return cn.equals(cname);
            } else {
                return cn.equals(cname) && info.user.equals(user);
            }
        }
    };
    return filterItemInfos(sBgItemsIdMap, filter);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:15,代码来源:LauncherModel.java

示例10: containsInExcluded

import android.content.ComponentName; //导入方法依赖的package包/类
/**
 * 当前这个 activityInfo 是否包含在 {@link #mExcluded} 中
 *
 * @return 如果包含在 {@link #mExcluded} 中,则返回 true;否则返回 false。
 */
private Boolean containsInExcluded(@NonNull ActivityInfo activityInfo) {
    Preconditions.checkNotNull(activityInfo, "activityInfo == null");
    if (mExcluded == null || mExcluded.size() == 0) {
        return false;
    }
    ComponentName componentName = new ComponentName(activityInfo.getPkg(),
            activityInfo.getCls());
    for (ComponentName excluded : mExcluded) {
        if (excluded.equals(componentName)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:JulianAndroid,项目名称:AppChooser,代码行数:20,代码来源:ResolversPresenter.java


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