use of sugar.free.sightremote.services.AlertService in project SightRemote by TebbeUbben.
the class AlertActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
String selectedTone = getStringPref(PREF_STRING_ALERT_ALARM_TONE);
Uri uri = selectedTone == null ? RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE) : Uri.parse(selectedTone);
ringtone = RingtoneManager.getRingtone(this, uri);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = 1.0F;
getWindow().setAttributes(layoutParams);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
if (savedInstanceState == null)
alertMessage = (ActiveAlertMessage) SerializationUtils.deserialize(getIntent().getByteArrayExtra("alertMessage"));
else
alertMessage = (ActiveAlertMessage) SerializationUtils.deserialize(savedInstanceState.getByteArray("alertMessage"));
setContentView(getLayoutFile());
alertCode = findViewById(R.id.alert_code);
alertTitle = findViewById(R.id.alert_title);
alertDescription = findViewById(R.id.alert_description);
mute = findViewById(R.id.mute);
dismiss = findViewById(R.id.dismiss);
mute.setOnClickListener(this);
dismiss.setOnClickListener(this);
setAlertCode();
setAlertTitle();
setAlertDescription();
update();
bindService(new Intent(this, AlertService.class), serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
alertService = ((AlertService.AlertServiceBinder) service).getService();
alertService.setAlertActivity(AlertActivity.this);
}
@Override
public void onServiceDisconnected(ComponentName name) {
finish();
}
}, BIND_AUTO_CREATE);
}
Aggregations