當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。