本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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());
}