RSS

Counter display code in SMS

26 Oct

Core Logic:
Counter Display = No of Chars Left / Required SMS Count

private final TextWatcher mTextEditorWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
//This sets a textview to the current length
String smsNo;
if(s.length() == 0)
smsNo = "0";
else
smsNo = String.valueOf(s.length()/160 + 1);
String smsLength = String.valueOf(160-(s.length()%160));
mCounter.setText(smsLength+"/"+smsNo);
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
};

Reference: http://www.vineetdhanawat.com/blog/2012/04/how-to-use-broadcast-receiver-in-android-send-and-receive-sms/

Advertisements
 
Leave a comment

Posted by on October 26, 2012 in Android Source Code

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: