Make a Timer App: Settings (Ep 5) – Android Kotlin Tutorial

In this course you will learn how to make a user interface. Later we’re going to code a timer which can run in the foreground. Then we are going to upgrade it to be able to run also in the background – and we will control it from notifications! Finally we will create a settings activity where a user will be able to set the length of the timer.

In this fifth and final part we’re creating settings for our timer app! They are pretty simple – we will be able to set the length of the timer. You will learn how to work with Android’s preferences so let’s get to it!

 

This post contains all the code that’s been written in this YouTube video.

 

You can also check out this GitHub repository: https://github.com/ResoCoder/TimerAppAndroidTutorial

 

preferences.xml

 

SettingsActivity.kt

 

SettingsActivityFragment.kt

 

PrefUtil.kt

 

activity_settings.xml

 

TimerActivity.kt

Leave a comment


This site uses Akismet to reduce spam. Learn how your comment data is processed.


Daniel

6 months ago

Cool tutorial, thanks!

one question:
If I want to set the timer to 6 hours, how can I handle doze mode?

Matej Rešetár

5 months ago

I’m not entirely sure because I’ve never done it but in the docs it writes that you should set the alarm by calling setAndAllowWhileIdle(). https://developer.android.com/training/monitoring-device-state/doze-standby.html

Development made simple

Your success is our success. If you have any questions, let us know.

Copyright 2017 - 2018 Reso Coder © All Rights Reserved