當前位置: 首頁>>代碼示例>>Java>>正文


Java UserManager.getApplicationRestrictions方法代碼示例

本文整理匯總了Java中android.os.UserManager.getApplicationRestrictions方法的典型用法代碼示例。如果您正苦於以下問題:Java UserManager.getApplicationRestrictions方法的具體用法?Java UserManager.getApplicationRestrictions怎麽用?Java UserManager.getApplicationRestrictions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.UserManager的用法示例。


在下文中一共展示了UserManager.getApplicationRestrictions方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createWorkspaceLoaderFromAppRestriction

import android.os.UserManager; //導入方法依賴的package包/類
/**
 * Creates workspace loader from an XML resource listed in the app restrictions.
 *
 * @return the loader if the restrictions are set and the resource exists; null otherwise.
 */
private AutoInstallsLayout createWorkspaceLoaderFromAppRestriction(AppWidgetHost widgetHost) {
    Context ctx = getContext();
    UserManager um = (UserManager) ctx.getSystemService(Context.USER_SERVICE);
    Bundle bundle = um.getApplicationRestrictions(ctx.getPackageName());
    if (bundle == null) {
        return null;
    }

    String packageName = bundle.getString(RESTRICTION_PACKAGE_NAME);
    if (packageName != null) {
        try {
            Resources targetResources = ctx.getPackageManager()
                    .getResourcesForApplication(packageName);
            return AutoInstallsLayout.get(ctx, packageName, targetResources,
                    widgetHost, mOpenHelper);
        } catch (NameNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
    return null;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:28,代碼來源:LauncherProvider.java

示例2: updateEnabledState

import android.os.UserManager; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void updateEnabledState() {
    // This method uses AppRestrictions directly, rather than using the Policy interface,
    // because it must be callable in contexts in which the native library hasn't been
    // loaded. It will always be called from a background thread (except possibly in tests)
    // so can get the App Restrictions synchronously.
    UserManager userManager = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
    Bundle appRestrictions = userManager
            .getApplicationRestrictions(getContext().getPackageName());
    setEnabled(appRestrictions.getBoolean(SUPERVISED_USER_CONTENT_PROVIDER_ENABLED));
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:12,代碼來源:SupervisedUserContentProvider.java

示例3: createWorkspaceLoaderFromAppRestriction

import android.os.UserManager; //導入方法依賴的package包/類
/**
 * Creates workspace loader from an XML resource listed in the app restrictions.
 *
 * @return the loader if the restrictions are set and the resource exists; null otherwise.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private AutoInstallsLayout createWorkspaceLoaderFromAppRestriction(AppWidgetHost widgetHost) {
    // UserManager.getApplicationRestrictions() requires minSdkVersion >= 18
    if (!Utilities.ATLEAST_JB_MR2) {
        return null;
    }

    Context ctx = getContext();
    UserManager um = (UserManager) ctx.getSystemService(Context.USER_SERVICE);
    Bundle bundle = um.getApplicationRestrictions(ctx.getPackageName());
    if (bundle == null) {
        return null;
    }

    String packageName = bundle.getString(RESTRICTION_PACKAGE_NAME);
    if (packageName != null) {
        try {
            Resources targetResources = ctx.getPackageManager()
                    .getResourcesForApplication(packageName);
            return AutoInstallsLayout.get(ctx, packageName, targetResources,
                    widgetHost, mOpenHelper);
        } catch (NameNotFoundException e) {
            Log.e(TAG, "Target package for restricted profile not found", e);
            return null;
        }
    }
    return null;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:34,代碼來源:LauncherProvider.java

示例4: createWorkspaceLoaderFromAppRestriction

import android.os.UserManager; //導入方法依賴的package包/類
/**
 * Creates workspace loader from an XML resource listed in the app restrictions.
 *
 * @return the loader if the restrictions are set and the resource exists; null otherwise.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private AutoInstallsLayout createWorkspaceLoaderFromAppRestriction() {
    // UserManager.getApplicationRestrictions() requires minSdkVersion >= 18
    if (!Utilities.ATLEAST_JB_MR2) {
        return null;
    }

    Context ctx = getContext();
    UserManager um = (UserManager) ctx.getSystemService(Context.USER_SERVICE);
    Bundle bundle = um.getApplicationRestrictions(ctx.getPackageName());
    if (bundle == null) {
        return null;
    }

    String packageName = bundle.getString(RESTRICTION_PACKAGE_NAME);
    if (packageName != null) {
        try {
            Resources targetResources = ctx.getPackageManager()
                    .getResourcesForApplication(packageName);
            return AutoInstallsLayout.get(ctx, packageName, targetResources,
                    mOpenHelper.mAppWidgetHost, mOpenHelper);
        } catch (NameNotFoundException e) {
            Log.e(TAG, "Target package for restricted profile not found", e);
            return null;
        }
    }
    return null;
}
 
開發者ID:Mr-lin930819,項目名稱:SimplOS,代碼行數:34,代碼來源:LauncherProvider.java

示例5: getAppRestrictions

import android.os.UserManager; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private Bundle getAppRestrictions(final Context context) {
    final UserManager mgr = (UserManager) context.getSystemService(Context.USER_SERVICE);
    return mgr.getApplicationRestrictions(context.getPackageName());
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:6,代碼來源:RestrictedProfileConfiguration.java


注:本文中的android.os.UserManager.getApplicationRestrictions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。