Trevor Johns | 296083e | 2015-05-27 13:18:28 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2015 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.system.runtimepermissions; |
| 18 | |
| 19 | import android.os.Bundle; |
| 20 | import android.support.annotation.Nullable; |
| 21 | import android.support.v4.app.Fragment; |
| 22 | import android.view.LayoutInflater; |
| 23 | import android.view.View; |
| 24 | import android.view.ViewGroup; |
| 25 | |
| 26 | public class RuntimePermissionsFragment extends Fragment { |
| 27 | |
| 28 | @Nullable |
| 29 | @Override |
| 30 | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
| 31 | Bundle savedInstanceState) { |
| 32 | View root = inflater.inflate(R.layout.fragment_main, null); |
| 33 | |
| 34 | // BEGIN_INCLUDE(m_only_permission) |
| 35 | if (!PermissionUtil.isMNC()) { |
| 36 | /* |
| 37 | The contacts permissions have been declared in the AndroidManifest for Android M only. |
| 38 | They are not available on older platforms, so we are hiding the button to access the |
| 39 | contacts database. |
| 40 | This shows how new runtime-only permissions can be added, that do not apply to older |
| 41 | platform versions. This can be useful for automated updates where additional |
| 42 | permissions might prompt the user on upgrade. |
| 43 | */ |
| 44 | root.findViewById(R.id.button_camera).setVisibility(View.GONE); |
| 45 | } |
| 46 | // END_INCLUDE(m_only_permission) |
| 47 | |
| 48 | return root; |
| 49 | } |
| 50 | } |