I am working on an alarm clock. As part of this, I have IntentServiceone that starts the action when the alarm really turns off. In Activity, onCreateI wake up on the screen, getting the vocals blocked, causing the activity to go full screen and playing the sound. Here's everything onCreate:
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
int id = extras.getInt("AlarmID", -1);
DB = new DatabaseHelper(this);
alarm = DB.getAlarm(id);
if (alarm == null || !alarm.isEnabled()) finish();
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_alarm);
View contentView = findViewById(R.id.fullscreen_content);
ActionBar bar = getActionBar();
if (bar != null) bar.hide();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS);
mSystemUiHider.setup();
mSystemUiHider.hide();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "MyWakeLock");
wakeLock.acquire();
TextView time = (TextView)findViewById(R.id.Time);
TextView name = (TextView)findViewById(R.id.SmallAlarmName);
time.setText(Alarm.FormatTime(alarm.getHour(), alarm.getMinute()));
name.setText(alarm.getName());
tone = RingtoneManager.getRingtone(this, alarm.getSound());
tone.setStreamType(RingtoneManager.TYPE_ALARM);
tone.play();
The view is pretty simple: 2x TextViews to show the time and name of the alarm, and 2x clickable ImageViews for snooze and disable.
, , , , , . ImageViews Log.i, , , . . ImageView. , , . , , ?
Nexus 5, 4.4.3, Rooted, , Xposed Framework ( , ). - ( VM ).
, . , , .
EDIT: , - . , setFlags addFlags getWindow().setFlags(...). addFlags :
int flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
getWindow().addFlags(flags);
.
, , ?
onCreate , , . ImageViews, , .
2: , -. , , . logcat :
06-12 23:28:04.437 812-844/? W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
. , , .
, . , , , . , , .