Im trying to send a sms and an email after the phone is get booted.
The email is being sent but sms is not being sent. The same message is
being sent from another activity when I run the application after the
phone get botted. I am using emulator for sending mail and messages.
I have setup the proper permissions in menifest file. Here is the
code for SentSMS.class
<code>
import android.telephony.SmsManager;
public class SendSMS{
public void sendSMS(String phoneNumber, String msg){
SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage(phoneNumber, null, msg, null, null);
}
}
</code>
and here is how I am sending it after boot.
<code>
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.telephony.TelephonyManager;
import android.util.Log;
public class NotifyOnBoot extends Service {
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
Thread th = new Thread(null, task, "NotifyingService");
th.start();
}
private Runnable task = new Runnable() {
public void run() {
SendSMS mysms = new SendSMS();
mysms.sendSMS("5556", "hi");
NotifyOnBoot.this.stopSelf();
}
};
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public int onStartCommand (Intent intent, int flags, int
startId){
return START_STICKY;
}
}
</code>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en