SMS text counter in Android
I want to implement SMS text counter like feature as in Android default messaging application. So that after e开发者_开发知识库ach 161 character counter should be incremented by one and on deleting of character it should decrease.
Math.floor(chars / 160) + 1
This will divide the number of characters you have by the SMS-limit (160), cut off the decimal place and add "1".
http://www.java-examples.com/find-floor-value-number-using-math.floor
e.g. chars = 170, then (chars / 160) = 1,0625 and floor(1,0625) = 1, the result would be that 170 characters mean 2 SMS.
Something like:
int countSMS = (nbOfCharacters / 160) + 1;
精彩评论