Problem in sending sms

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Problem in sending sms

Postby Nemat » Thu Jan 21, 2010 7:18 am

Hi.....

I am trying to send sms using SmsManager class.Here is my code:

PendingIntent pi = PendingIntent.getActivity(this, 0,
new Intent(this, SMSSender.class), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("9001100444", null, "This is test message", pi, null);

SMS is sent successfully but it is sent two times on the same phone-number and aving same content.

I dont get the problem.Can anyone describe me the reason of this problem.....??

Thanks in Advance
Nemat
Nemat
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Thu Aug 21, 2008 3:16 pm
Location: Jaipur

Top

Postby jwei512 » Wed Jan 27, 2010 12:23 am

Is your class name called SMSSender? In which case this pending intent

PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, SMSSender.class), 0);

would essentially start another instance of the same class and send the SMS again?

That might be what's happening... not sure though if it's not you might have to post more of your code in order for us to help you track down the problem.
- jwei

http://thinkandroid.wordpress.com
Examples, Code, and Tutorials
jwei512
Senior Developer
Senior Developer
 
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA

Postby Nemat » Wed Jan 27, 2010 11:16 am

but it also happens when I use another constructor of intent.Here is
my code:

PendingIntent pi = PendingIntent.getActivity(this, 0,
new Intent(), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("9001100444", null, "This is test message", pi,
null);


Thanks
Nemat
Nemat
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Thu Aug 21, 2008 3:16 pm
Location: Jaipur

how to block sendTextMessage until SMS_DELIVERED ?

Postby www.rzr.online.fr » Thu Feb 04, 2010 11:06 am

Havent you tried to use "PendingIntent.getBroadcast" ?

by the way i am curious how to makes sendTextMessage blocking until delivery status, I tried various options but it looks that the service starts once the UI thread is vacant (once the callback method returns) ? The documentation is not very verbose about how sendTextMessage is working ...
User avatar
www.rzr.online.fr
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Feb 03, 2009 11:39 am
Location: fr/35/rennes

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 8 guests