SimonMarquis/SleepTimer
Über uns
💤 Simplest Sleep Timer
Design und MedienGemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
OriginalSleep Timer
| Quick Settings Tile | Notification | Live Update |
|---|---|---|
![]() |
![]() |
![]() |
Sleep Timer helps you fall asleep while listening to music or podcasts.
When the timer stops, audio playback is gradually lowered then paused.
Usage
- Add the Tile in the Quick Settings panel.
- Tap the Tile to start a timer.
- Extend, reduce or cancel the timer with the notification actions.
Note: Don't look for a launcher icon, this app only provides a Quick Settings Tile.
Automation
You can trigger the Sleep Timer with tools like Tasker or by using adb commands:
- Start the timer
adb shell am broadcast -a fr.smarquis.sleeptimer.action.START -n fr.smarquis.sleeptimer/.SleepActionReceiver - Start the timer with custom duration (10 min)
adb shell am broadcast -a fr.smarquis.sleeptimer.action.START -n fr.smarquis.sleeptimer/.SleepActionReceiver --el extras:duration 600 - Update the timer (-1 min)
adb shell am broadcast -a fr.smarquis.sleeptimer.action.UPDATE -n fr.smarquis.sleeptimer/.SleepActionReceiver --el extras:duration -60 - Stop the timer
adb shell am broadcast -a fr.smarquis.sleeptimer.action.STOP -n fr.smarquis.sleeptimer/.SleepActionReceiver - Increment (default +10 min)
adb shell am broadcast -a fr.smarquis.sleeptimer.action.INCREMENT -n fr.smarquis.sleeptimer/.SleepActionReceiver - Decrement (default -10 min)
adb shell am broadcast -a fr.smarquis.sleeptimer.action.DECREMENT -n fr.smarquis.sleeptimer/.SleepActionReceiver
APIs
- Tile and TileService: Quick Settings Tile
- Notification.Builder.setTimeoutAfter(durationMs): set notification timeout.
- Notification.Builder.setDeleteIntent(intent): set deletion action.
- NotificationCompat.Builder.setRequestPromotedOngoing(requestPromotedOngoing): request to be a promoted ongoing notification
- AudioManager.adjustStreamVolume(STREAM_MUSIC, ADJUST_LOWER, flags): lower media volume.
- AudioManager.setStreamVolume(STREAM_MUSIC, index, flags): restore initial volume.
- AudioManager.dispatchMediaKeyEvent(KeyEvent): sends a simulated key event for a media button.
[!IMPORTANT]
Android 17 introduced Background audio hardening which prevents callingAudioManager.adjustStreamVolume(streamType, direction, flags)from a background thread.
And the system does not allowPendingIntentused inNotification.Builder.setDeleteIntent(intent)to reference a foregroundService.
Therefore, an alarm must be scheduled at a precise time to trigger such foregroundServiceand pause audio playback.
- AlarmManager.setExactAndAllowWhileIdle(type, triggerAtMillis, PendingIntent): schedule a system alarm.
License
Copyright 2020 Simon Marquis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed: in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Ähnliche Projekte entdecken
Wird geladen…


