Reputation: 2321
I have a SMS counter that count typed character;
I wanna when user type English
char(English chars + sings + numbers) ,counting Variable do ++ to Number: 160
,
But , if in all there r a Persian
char , counting Variable do ++ to Number: 70
what I should to do?
I Fined that this code : var ucs2 = text.search(/[^\x00-\x7D]/)
in php
return What character user ; Persian char or English.
The equivalent code in Java - What is Android؟
private final TextWatcher TextWatcher_Method = new TextWatcher()
{
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
{
cnt2=matn_counter.length();
TextView counter=(TextView)findViewById(R.id.txt_counter);
cnt1=(int) Math.ceil(cnt2/6);
Integer cnt3=(cnt2%6);
counter.setText(Integer.toString(cnt1)+"/"+Integer.toString(cnt3));
}
}
Upvotes: 3
Views: 1749
Reputation: 1698
The Answer:
Actually you should check ASCII chars.
If any char is out of ASCII range (0x0000 to 0x007F) the message becomes to 70 length limit.
And otherwise as you motioned, if all chars is ASCII (for example English letters or numbers) the limitation on message length is 160.
the code is simple:
public static boolean isASCIIMessage(String s) {
for (int i = 0; i < Character.codePointCount(s, 0, s.length()); i++) {
int c = s.codePointAt(i);
if (c >= 0x0000 && c <=0x007F)
return false;
}
return true;
Anyway if you want detect Persian input see this answer.
Upvotes: 0
Reputation: 111
Here's some useful tips on how to send SMS, make call, etc... http://www.apurbadebnath.com/blog/android-emulator-tips/
Upvotes: 1
Reputation: 6857
You can't send 'real' SMS from emulator to device, because you don't have a SIM card.
You can, however, send it from emulator to emulator if you have more than one running.
To do this, check this question: Sending and receiving text using android emulator
Upvotes: 2