점차 밝기를 변경해야하는 Runnable을 실행합니다.
private Runnable runnable = new Runnable(){
@Override
public void run(){
if(intensity < 1){ intensity += intensityGrow; }
if(intensity > 1){ intensity = 1f; }
Log.e("intensity", intensity + "/grow "+intensityGrow);
android.provider.Settings.System.putInt(
getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS,(int)(255*intensity)
);
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
am.setStreamVolume(
AudioManager.STREAM_ALARM, (int) (am.getStreamMaxVolume(AudioManager.STREAM_ALARM) * intensity), 0
);
if(intensity < 1){
Log.e("intensity", "continue");
handler.postDelayed(runnable, 1000);
}
}
};
나는 또한 사용하려고
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = intensity;
getWindow().setAttributes(lp);
이 <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
결과없이 또한 매니페스트.
처음에이 작업을 수행하려면 밝기 모드를 수동으로 설정해야합니다.
Settings.System.putInt(
getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL
);
그런 다음 두 가지 방법을 사용하여 밝기를 변경하십시오.
android.provider.Settings.System.putInt(
getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS, (int) (255 * intensity)
);
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = intensity;
getWindow().setAttributes(lp);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다