アプリの画面を固定するには "AndroidManifest.xml" を編集し、アクティビティごとに以下の属性を追加します。
- 縦画面固定の場合
activity android:screenOrientation="portrait"
- 横画面固定の場合
activity android:screenOrientation="landscape"
activity android:screenOrientation="portrait"
activity android:screenOrientation="landscape"
<uses-permission android:name="android.permission.VIBRATE" />
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.1"
@Override
protected void onResume() {
super.onResume();
manager = (SensorManager)getSystemService(SENSOR_SERVICE);
List<Sensor> sensors =
manager.getSensorList(Sensor.TYPE_ACCELEROMETER);
if (0 < sensors.size()) {
manager.registerListener(
this, sensors.get(0),
SensorManager.SENSOR_DELAY_NORMAL);
}
SharedPreferences sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(this);
String color = sharedPreferences.getString("background", "GREEN");
if (color.equals("GREEN")){
framelayout.setBackgroundColor(Color.GREEN);
} else {
framelayout.setBackgroundColor(Color.BLUE);
}
}