From the course: Writing Secure Code for Android by Infosec

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Activity: Clamping input to a range

Activity: Clamping input to a range

- [Instructor] Input sanitization. Activity: Clamping Input to a Range. Open up your Android Studio's activity folder. Go to course two and go to Clamping Input to a Range and find the text file Clamping Input to a Range snippet and open that up. Copy all of it and get yourself to a Kotlin playground of some kind. I like play.kotlinlang.org and paste it in. Now what we're just doing here is we are, what we're doing in this activity is we're going to specify a range, and we're going to say that if something falls outside that range, we're going to clamp or we're going to set it to either the minimum or maximum, depending on if it fell below or fell above. In this particular activity, we are testing a chemical solution and we're saying that the range is the acceptable range of the pH, it's acidity in it's alkalinity. And if it falls too low or if it falls too high, we're going to clamp it to the minimum and maximum values. And you might say, but I'm never going to work on an app that…

Contents