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


Java ActivityManager.getCurrentUser方法代码示例

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


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

示例1: loadNotifications

import android.app.ActivityManager; //导入方法依赖的package包/类
private List<HistoricalNotificationInfo> loadNotifications() {
    final int currentUserId = ActivityManager.getCurrentUser();
    try {
        StatusBarNotification[] active = mNoMan.getActiveNotifications(
                mContext.getPackageName());
        StatusBarNotification[] dismissed = mNoMan.getHistoricalNotifications(
                mContext.getPackageName(), 50);

        List<HistoricalNotificationInfo> list
                = new ArrayList<HistoricalNotificationInfo>(active.length + dismissed.length);

        for (StatusBarNotification[] resultset
                : new StatusBarNotification[][] { active, dismissed }) {
            for (StatusBarNotification sbn : resultset) {
                final HistoricalNotificationInfo info = new HistoricalNotificationInfo();
                info.pkg = sbn.getPackageName();
                info.user = sbn.getUserId();
                info.icon = loadIconDrawable(info.pkg, info.user, sbn.getNotification().icon);
                info.pkgicon = loadPackageIconDrawable(info.pkg, info.user);
                info.pkgname = loadPackageName(info.pkg);
                if (sbn.getNotification().extras != null) {
                    info.title = sbn.getNotification().extras.getString(
                            Notification.EXTRA_TITLE);
                    if (info.title == null || "".equals(info.title)) {
                        info.title = sbn.getNotification().extras.getString(
                                Notification.EXTRA_TEXT);
                    }
                }
                if (info.title == null || "".equals(info.title)) {
                    info.title = sbn.getNotification().tickerText;
                }
                // still nothing? come on, give us something!
                if (info.title == null || "".equals(info.title)) {
                    info.title = info.pkgname;
                }
                info.timestamp = sbn.getPostTime();
                info.priority = sbn.getNotification().priority;
                logd("   [%d] %s: %s", info.timestamp, info.pkg, info.title);

                info.active = (resultset == active);

                if (info.user == UserHandle.USER_ALL
                        || info.user == currentUserId) {
                    list.add(info);
                }
            }
        }

        return list;
    } catch (RemoteException e) {
        Log.e(TAG, "Cannot load Notifications: ", e);
    }
    return null;
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:55,代码来源:NotificationStation.java

示例2: getServices

import android.app.ActivityManager; //导入方法依赖的package包/类
private static int getServices(Config c, List<ServiceInfo> list, PackageManager pm) {
    int services = 0;
    if (list != null) {
        list.clear();
    }
    final int user = ActivityManager.getCurrentUser();

    List<ResolveInfo> installedServices = pm.queryIntentServicesAsUser(
            new Intent(c.intentAction),
            PackageManager.GET_SERVICES | PackageManager.GET_META_DATA,
            user);

    for (int i = 0, count = installedServices.size(); i < count; i++) {
        ResolveInfo resolveInfo = installedServices.get(i);
        ServiceInfo info = resolveInfo.serviceInfo;

        if (!c.permission.equals(info.permission)) {
            Slog.w(c.tag, "Skipping " + c.noun + " service "
                    + info.packageName + "/" + info.name
                    + ": it does not require the permission "
                    + c.permission);
            continue;
        }
        if (list != null) {
            list.add(info);
        }
        services++;
    }
    return services;
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:31,代码来源:ServiceListing.java

示例3: getCurrentUser

import android.app.ActivityManager; //导入方法依赖的package包/类
public static int getCurrentUser() {
    return ActivityManager.getCurrentUser();
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:4,代码来源:HideApiOverride.java


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