blob: b35bfebc092d6fbb3b3da8039e4cd3cb89cc82e0 [file] [log] [blame]
Trevor Johns296083e2015-05-27 13:18:28 -07001/*
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
17package com.example.android.system.runtimepermissions;
18
19import android.os.Bundle;
20import android.support.annotation.Nullable;
21import android.support.v4.app.Fragment;
22import android.view.LayoutInflater;
23import android.view.View;
24import android.view.ViewGroup;
25
26public 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}