Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid : SMS is being received multiple times
    primarykey
    data
    text
    <p>I have service which sends SMS at specified time but i noticed that same message is being received multiple times. don't know why it happens.</p> <p>After setting a time to send SMS <code>11:45 pm</code>, i got same message 4 times at <code>11:45 pm</code>, <code>05:58 am</code>,<code>09:58 am</code> and <code>01:01 pm</code></p> <p>Here is my code for send SMS:</p> <pre><code>Intent myIntent = new Intent(AlarmActivity.this, SendSmsService.class); pendingIntent = PendingIntent.getService(AlarmActivity.this, 0, myIntent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, TimePreference.getHour(sendTime)); cal.set(Calendar.MINUTE, TimePreference.getMinute(sendTime)); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent); </code></pre> <p>And here is <strong>SendSmsService.java</strong></p> <pre><code>public class SendSmsService extends Service { private static final String TAG = SendSmsService.class.getSimpleName(); String CompleteAddr, eContact1, eContact2, eContact3; String smsString; boolean acknowledged; @Override public void onCreate() { // TODO Auto-generated method stub Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show(); super.onCreate(); } @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { // TODO Auto-generated method stub Log.v(TAG, "onStartCommand"); getSharedSettings(); if (acknowledged == false) { if (eContact1 != "") sendSMS(eContact1, smsString + CompleteAddr); if (eContact2 != "") sendSMS(eContact2, smsString + CompleteAddr); if (eContact3 != "") sendSMS(eContact3, smsString + CompleteAddr); } return super.onStartCommand(intent, flags, startId); } @Override public boolean onUnbind(Intent intent) { // TODO Auto-generated method stub return super.onUnbind(intent); } private void sendSMS(String phoneNumber, String message) { SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(phoneNumber, null, message, null, null); } } </code></pre> <p>Any suggestion and idea will be appreciated <br> Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload