Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage restricted profiles in android app?

Restricted profile are now available in android from 4.3, i came to know that some apps like camera, gmail etc are not available in these kind of profiles. How can i manage these type of conditions in my app? Also how to manage in app products and restricted profile settings in corresponding to my app?

like image 364
Arun C Avatar asked Jul 25 '13 10:07

Arun C


People also ask

What is restricted profile on Android?

You can prevent people from using specific apps or games on your Android TV by setting up a restricted profile. If you're using a restricted profile, you cannot: Access or make purchases in the Google Play Store app.

How do I make a restricted profile on Android?

To make a restricted profile Open your tablet's Settings app. Tap Users & accounts > Users. Tap Add user or profile. Tap Restricted profile.


2 Answers

Thanks user370305 even if i already visited

http://developer.android.com/about/versions/android-4.3.html#RestrictedProfiles

I would like to improve it from reference with

https://www.youtube.com/watch?v=pdUcANNm72o

Restricted Profiles are a new feature introduced in Android Jelly Bean 4.3 that enables you to give users of your applications improved control when sharing their tablet.

These Restricted Profiles share apps, google account of primary user account but in a restricted manner.They dont get access to gmail, play store, calender etc. Primary user can select the restrictions for each applications.

UserManager Class is extended for managing these restrictions

UserManager.getUserRestrictions returns the user-wide restrictions imposed on the user specified

UserManager.getApplicationRestrictions returns a bundle containing any saved application restrictions for this user, for the given package name. Only an application with this package name can call this method.

If you need specific settings use this intent filter

<receiver android:name="GetRestrictionsReceiver">
<intent-filter>
<action android:name="android.intent.action.GET_RESTRICTION_ENTRIES "/>
</intent-filter>
</receiver>

now implement broadcast receiver with Restriction Entry list returned like this

public  class GetRestrictionsReceiver extends BroadcastReceiver
    {

        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub
            final PendingResult result=goAsync();
            new Thread(){
                public void run(){
                    final Bundle extras=new Bundle();
                    ArrayList<RestrictionEntry> newEntries = initRestricions(context);
                    extras.putParcelableArrayList(Intent.EXTRA_RESTRICTIONS_LIST, newEntries);

                    result.setResult(Activity.RESULT_OK, null, extras);
                    result.finish();
                }

            }.start();

        }


    }

RestrictionEntry

Any application that chooses to expose such restrictions does so by implementing a receiver that handles theACTION_GET_RESTRICTION_ENTRIES action. The receiver then returns a result bundle that contains an entry called "restrictions", whose value is an ArrayList.

There are 3 types of Restriction Entry

  1. Boolean
  2. Single Choice
  3. Multiple Choice

You can use different methods of RestrictionEntry to set and get different type of restrictions.

To get access to an account from a restricted profile, you must add the android:restrictedAccountType attribute to the tag:

<application ...
    android:restrictedAccountType="com.example.account.type" >
like image 110
Arun C Avatar answered Sep 21 '22 09:09

Arun C


The UI for users to control the restrictions you've built is managed by the system's Settings application. To make your app's restriction settings appear to the user, you must declare the restrictions your app provides by creating a BroadcastReceiver that receives the ACTION_GET_RESTRICTION_ENTRIES intent. The system invokes this intent to query all apps for available restrictions, then builds the UI to allow the primary user to manage restrictions for each restricted profile.

For more info look at http://developer.android.com/about/versions/android-4.3.html#RestrictedProfiles

like image 26
user370305 Avatar answered Sep 17 '22 09:09

user370305