最終更新:
moonlight_aska 2013年07月31日(水) 00:27:49履歴
端末の画面の明るさを取得するには, Settings.Systemクラスの"SCREEN_BRIGHTNESS"定数を指定する.


- ScreenBrightness.java
- Settings.Systemクラスの"SCREEN_BRIGHTNESS"定数を指定して, 画面の明るさを取得する.
package com.moonlight_aska.android.screenbrightness;
import android.os.Bundle;
import android.provider.Settings;
import android.app.Activity;
import android.widget.TextView;
public class ScreenBrightness extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView text = (TextView)findViewById(R.id.text_label);
// 画面の明るさの取得(0-255)
String brightness = Settings.System.getString(this.getContentResolver(), "screen_brightness");
text.setText("明るさ:" + brightness);
}
}
コメントをかく