Home | History | Annotate | Download | only in apprestrictionenforcer
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.example.android.apprestrictionenforcer;
     18 
     19 import android.app.admin.DevicePolicyManager;
     20 import android.content.ComponentName;
     21 import android.content.Context;
     22 import android.content.Intent;
     23 import android.os.Bundle;
     24 import android.support.v4.app.FragmentActivity;
     25 
     26 /**
     27  * This activity is started after the provisioning is complete in
     28  * {@link EnforcerDeviceAdminReceiver}.
     29  */
     30 public class EnableProfileActivity extends FragmentActivity {
     31 
     32     @Override
     33     protected void onCreate(Bundle savedInstanceState) {
     34         super.onCreate(savedInstanceState);
     35         if (null == savedInstanceState) {
     36             // Enable the newly created profile
     37             DevicePolicyManager manager =
     38                     (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
     39             ComponentName componentName = EnforcerDeviceAdminReceiver.getComponentName(this);
     40             manager.setProfileName(componentName, getString(R.string.profile_name));
     41             manager.setProfileEnabled(componentName);
     42         }
     43         // Open the main screen
     44         startActivity(new Intent(this, MainActivity.class));
     45         finish();
     46     }
     47 
     48 }
     49