BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-10-2012, 03:38 PM   #1
Lukaszz
New Member
 
Join Date: Feb 2012
Model: 9160
PIN: N/A
Carrier: vodacom
Posts: 4
Smile Read incoming sms without spaces

Please Login to Remove!

Hi,

The following code reads an incoming sms then prints the body of the message. How do I get the app to print out the message without any spaces inbetween?

For example: The incoming sms reads "Here I am", so "Here I am" is printed out, but I want the app to print out "HereIam".

How can I do this? Any help would be most appreciated.

Here is my code:

public void run() {

try {

DatagramConnection _dc =
(DatagramConnection)Connector.open("sms://");

for(;;) {

Datagram d = _dc.newDatagram(_dc.getMaximumLength());
_dc.receive(d);
byte[] bytes = d.getData();
String address = d.getAddress();
String msg = new String(bytes);
System.out.println(address);
System.out.println(msg);

}

}catch (Exception me) { }
}



Thanks
Offline  
Old 07-11-2012, 12:56 PM   #2
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default Re: Read incoming sms without spaces

I would create a new StringBuffer, then loop though the characters in the original string, appending each non-blank (!= '32') char to the StringBuffer.
Offline  
Old 07-11-2012, 04:11 PM   #3
Lukaszz
New Member
 
Join Date: Feb 2012
Model: 9160
PIN: N/A
Carrier: vodacom
Posts: 4
Default Re: Read incoming sms without spaces

Can you please provide me some code or a link that I can go to to read up on how to go about doing that?
Offline  
Old 07-12-2012, 10:58 AM   #4
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default Re: Read incoming sms without spaces

You can't iterate though the chars of a string?

Do you understand the concept of a for{} loop?

- create the string buffer
- get the length of the original message
- enter the for{} look, indexing through the chars of the string until you hit the end
- for each char that is not a ' ' (32), append the char to the string buffer.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads for: Read incoming sms without spaces
Thread Thread Starter Forum Replies Last Post
Sync Error Code 0x80040fb3 for pete's sake General BlackBerry Discussion 2 05-24-2010 02:56 PM
[New Software] Quicker SMS for BlackBerry Launched Joe Ge Aftermarket Software 8 07-18-2009 07:07 PM
My sms messages are still showing up on the today theme even though i have read them? cody BlackBerry Themes 4 02-14-2008 12:01 PM
SMS messaging for Nextel's 7520 Q14 General BlackBerry Discussion 28 06-14-2006 10:14 AM


OEM Battery for MacBook Pro 17

OEM Battery for MacBook Pro 17" A1309 A1297 Early 2009 Mid 2009 2010 MC226

$42.80



NEW OEM A1618 Battery for Apple MacBook Pro 15” Retina 99.5Wh A1398 Mid 2015 picture

NEW OEM A1618 Battery for Apple MacBook Pro 15” Retina 99.5Wh A1398 Mid 2015

$49.90



Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013 picture

Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013

$37.90



NEW OEM Battery A1466 A1369 A1496 A1405 A1377 A1466 for MacBook Air 13 inch picture

NEW OEM Battery A1466 A1369 A1496 A1405 A1377 A1466 for MacBook Air 13 inch

$35.90



Genuine OEM A1417 Battery For Apple Macbook Pro 15

Genuine OEM A1417 Battery For Apple Macbook Pro 15" Retina A1398 2012 2013 NEW

$38.90



A1618 NEW OEM Battery for MacBook Pro 15

A1618 NEW OEM Battery for MacBook Pro 15" Retina A1398 Mid 2015 020-00079

$49.90







Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.