SMS_Receiver/SMS_Sender

Put your problem here if it does not fit any of the other categories.

SMS_Receiver/SMS_Sender

Postby burmat » Sat Jan 08, 2011 8:26 pm

I'm making a widget that will start a broadcast receiver, and send a auto-reply message to anyone that texts the device. My SmsReceiver class is working fine, but to launch my sendSMS method in my SMS_Sender class, I must change the method to static. This will not work however, because I have other receivers and intents to verify that the auto-reply is sent/delivered/etc. This is what I am trying to use to call my method from my SmsReceiver class:

Code: Select all
SMS_Sender.sendSMS(phoneNumber, messageText);


So my questions is, how do I launch a non-static method to and send an auto-reply from a broadcast receiver catching text incoming text messages.

Thanks in advance for any advice,
Nate
burmat
Junior Developer
Junior Developer
 
Posts: 11
Joined: Wed Mar 24, 2010 8:50 pm
Location: Syracuse, NY

Top

Re: SMS_Receiver/SMS_Sender

Postby Skiller » Sun Jan 09, 2011 5:55 pm

Just use it as a member function, create an SMS_Sender and call sendSMS from that. For example:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. SMS_Sender SMSSenderVariable = new SMS_Sender();
  2. SMSSenderVariable.sendSMS(phoneNumber, messageText);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

or if you aren't going to reuse SMSSenderVariable I believe you could just do:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. new SMS_Sender().sendSMS(phoneNumber, messageText);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4



If the problem is that you don't have access to a specific SMS_Sender you want because it was created somewhere else then the solution is highly dependent on how the code is structured and to be able to help you I'd need to see exactly where the SMS_Sender is created in relation to where it is needed.
Skiller
Developer
Developer
 
Posts: 33
Joined: Sun Nov 28, 2010 8:35 pm
Location: Australia

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests