I am working on an SMS receiver module in my app in which I am receiving an sms with my app, and if sms is more than 160 characters than I have to concate that SMS with its next part and display it. Currently I am working with a simple receiver code. Please suggest me to perform this task.
Asked
Active
Viewed 1,645 times
1 Answers
5
Yes, try as handle multipart messages :
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[])bundle.get("pdus");
final SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
}
StringBuffer content = new StringBuffer();
if (messages.length > 0) {
for (int i = 0; i < messages.length; i++) {
content.append(messages[i].getMessageBody());
}
}
String mySmsText = content.toString();
}
}
}

ρяσѕρєя K
- 132,198
- 53
- 198
- 213
-
Hello Imran, thanks alot for answering and providing a useful suggestion.....it worked. – Sam-In-TechValens Nov 28 '12 at 08:40