Example usage for android.content Intent EXTRA_RESTRICTIONS_BUNDLE

List of usage examples for android.content Intent EXTRA_RESTRICTIONS_BUNDLE

Introduction

In this page you can find the example usage for android.content Intent EXTRA_RESTRICTIONS_BUNDLE.

Prototype

String EXTRA_RESTRICTIONS_BUNDLE

To view the source code for android.content Intent EXTRA_RESTRICTIONS_BUNDLE.

Click Source Link

Document

Extra sent in the intent to the BroadcastReceiver that handles #ACTION_GET_RESTRICTION_ENTRIES .

Usage

From source file:com.android.tv.settings.users.AppRestrictionsFragment.java

/**
 * Send a broadcast to the app to query its restrictions
 * @param packageName package name of the app with restrictions
 * @param preference the preference item for the app toggle
 *///from  w ww  .  j a v  a  2 s  .com
private void requestRestrictionsForApp(String packageName, AppRestrictionsPreference preference) {
    Bundle oldEntries = mUserManager.getApplicationRestrictions(packageName, mUser);
    Intent intent = new Intent(Intent.ACTION_GET_RESTRICTION_ENTRIES);
    intent.setPackage(packageName);
    intent.putExtra(Intent.EXTRA_RESTRICTIONS_BUNDLE, oldEntries);
    intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
    getActivity().sendOrderedBroadcast(intent, null, new RestrictionsResultReceiver(packageName, preference),
            null, Activity.RESULT_OK, null, null);
}

From source file:com.android.tv.settings.users.AppRestrictionsFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    AppRestrictionsPreference pref = (AppRestrictionsPreference) findPreference(
            mCustomRequestMap.get(requestCode));
    if (pref == null) {
        Log.w(TAG, "Unknown requestCode " + requestCode);
        return;// www. j a  va  2 s .  co m
    }

    if (resultCode == Activity.RESULT_OK) {
        String packageName = getPackageFromKey(pref.getKey());
        ArrayList<RestrictionEntry> list = data.getParcelableArrayListExtra(Intent.EXTRA_RESTRICTIONS_LIST);
        Bundle bundle = data.getBundleExtra(Intent.EXTRA_RESTRICTIONS_BUNDLE);
        if (list != null) {
            // If there's a valid result, persist it to the user manager.
            pref.setRestrictions(list);
            mUserManager.setApplicationRestrictions(packageName,
                    RestrictionsManager.convertRestrictionsToBundle(list), mUser);
        } else if (bundle != null) {
            // If there's a valid result, persist it to the user manager.
            mUserManager.setApplicationRestrictions(packageName, bundle, mUser);
        }
    }
    // Remove request from the map
    mCustomRequestMap.remove(requestCode);
}