Reputation: 551
How can I implement code for sending messages to another device?
A method like
public void sndSms(String phoneNumber, String message)
Note: My class doesn't have extends Activity
and onCreate()
method. How can I implement sndSms()
method then?
Upvotes: 1
Views: 494
Reputation: 1137
I guess you've got to have an activity at some point. So you just need to pass its Context to your method.
public void sndSms(String phoneNumber, String message, Context context){
Intent smsIntent = new Intent(android.content.Intent.ACTION_SEND);
(...)
context.startActivity(smsIntent);
}
In activity simply use
xxx.sndSms("number", "message", myActivity.this);
Upvotes: 1
Reputation: 642
I have found this solution, when I thought I will have that problem as well. But it was not necessary for me.
http://www.dotnetexpertsforum.com/how-to-send-sms-programatically-in-android-t1548.html
Upvotes: 1