Search in sources :

Example 1 with AlertService

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);
}
Also used : ServiceConnection(android.content.ServiceConnection) IBinder(android.os.IBinder) ActiveAlertMessage(sugar.free.sightparser.applayer.messages.status.ActiveAlertMessage) AlertService(sugar.free.sightremote.services.AlertService) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Uri(android.net.Uri) WindowManager(android.view.WindowManager)

Aggregations

ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 ServiceConnection (android.content.ServiceConnection)1 Uri (android.net.Uri)1 IBinder (android.os.IBinder)1 WindowManager (android.view.WindowManager)1 ActiveAlertMessage (sugar.free.sightparser.applayer.messages.status.ActiveAlertMessage)1 AlertService (sugar.free.sightremote.services.AlertService)1