• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 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.android.development;
18 
19 import android.app.Activity;
20 import android.content.res.Configuration;
21 import android.os.Bundle;
22 import android.util.DisplayMetrics;
23 import android.util.Log;
24 import android.widget.TextView;
25 
26 public class ConfigurationViewer extends Activity {
27     @Override
onCreate(Bundle icicle)28     public void onCreate(Bundle icicle) {
29         super.onCreate(icicle);
30 
31         setContentView(R.layout.configuration_viewer);
32 
33         Configuration c = getResources().getConfiguration();
34         DisplayMetrics m = new DisplayMetrics();
35         getWindowManager().getDefaultDisplay().getMetrics(m);
36 
37         TextView tv = (TextView)findViewById(R.id.text);
38 
39         String s = "Configuration\n"
40                 + "\n"
41                 + "fontScale=" + c.fontScale + "\n"
42                 + "hardKeyboardHidden=" + c.hardKeyboardHidden + "\n"
43                 + "keyboard=" + c.keyboard + "\n"
44                 + "locale=" + c.locale + "\n"
45                 + "mcc=" + c.mcc + "\n"
46                 + "mnc=" + c.mnc + "\n"
47                 + "navigation=" + c.navigation + "\n"
48                 + "navigationHidden=" + c.navigationHidden + "\n"
49                 + "orientation=" + c.orientation + "\n"
50                 + "screenLayout=0x" + Integer.toHexString(c.screenLayout) + "\n"
51                 + "touchscreen=" + c.touchscreen + "\n"
52                 + "uiMode=0x" + Integer.toHexString(c.uiMode) + "\n"
53                 + "\n"
54                 + "DisplayMetrics\n"
55                 + "\n"
56                 + "density=" + m.density + "\n"
57                 + "densityDpi=" + m.densityDpi + "\n"
58                 + "heightPixels=" + m.heightPixels + "\n"
59                 + "scaledDensity=" + m.scaledDensity + "\n"
60                 + "widthPixels=" + m.widthPixels + "\n"
61                 + "xdpi=" + m.xdpi + "\n"
62                 + "ydpi=" + m.ydpi + "\n"
63                 ;
64 
65         tv.setText(s);
66 
67         // Also log it for bugreport purposes.
68         Log.d("ConfigurationViewer", s);
69     }
70 }
71 
72