How service will work in backgroud and foregroud.
git clone https://milankamariya@bitbucket.org/milankamariya/sky-music-player.git
- Pending intent notification with service.
Filter for Edit text for percentage value (like 100.00 , 99.99)
inner class MoneyValueFilter : DigitsKeyListener(false, true) { private var digits = 2 fun setDigits(d: Int) { digits = d } override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned, dstart: Int, dend: Int): CharSequence { var source = source var start = start var end = end val out = super.filter(source, start, end, dest, dstart, dend) // if changed, replace the source if (out != null) { source = out start = 0 end = out.length } val len = end - start // if deleting, source is empty // and deleting can't break anything if (len == 0) { return source } val dlen = dest.length try { // Get input val stringToMatch = dest.toString() + source.toString() val input = java.lang.Float.parseFloat(stringToMatch) val inputInt = input.toInt() val inputString = input.toString() if ((inputInt > 100)) { return ""; } if((inputInt == 100) && stringToMatch.contains("."))MoneyValueFilter
{
return "";
}
} catch (e: java.lang.Exception) {
}
// Find the position of the decimal . for (i in 0 until dstart) {
if (dest[i] == '.') {
// being here means, that a number has // been inserted after the dot // check if the amount of digits is right return if (dlen - (i + 1) + len > digits)
"" else SpannableStringBuilder(source, start, end)
}
}
for (i in start until end) {
if (source[i] == '.') {
// being here means, dot has been inserted // check if the amount of digits is right return if (dlen - dend + (end - (i + 1)) > digits)
"" else break // return new SpannableStringBuilder(source, start, end); }
}
// if the dot is after the inserted part, // nothing can break return SpannableStringBuilder(source, start, end)
}
private fun isInRange(min: Float, max: Float, input: Float): Boolean {
return input >= min && input <= max
}
}
Open Teminal/cmd --------------- Below steps is for Android 10 or lower Step 1 - Connect the device via USB and make sure debugging is work...