Ejemplo n.º 1
0
        private void execute(Context context, string numberDest, int idLstRep = 0)
        {
            desactiveSon = true;

            AudioManager aM = (AudioManager)context.GetSystemService(Context.AudioService);

            if (aM.RingerMode != RingerMode.Silent)
            {
                aM.RingerMode = RingerMode.Silent;
            }
            else
            {
                desactiveSon = false;
            }

            string     reponse = Global.Instance.GetElement(idLstRep).MessageText;
            SmsManager sms     = SmsManager.Default;

            if (reponse.Length > MAX_SMS_MESSAGE_LENGTH)
            {
                var messagelist = sms.DivideMessage(reponse);
                sms.SendMultipartTextMessage(numberDest, null, messagelist, null, null);
            }
            else
            {
                sms.SendTextMessage(numberDest, null, reponse, null, null);
            }

            Sleep(aM, context);
        }
Ejemplo n.º 2
0
        void SendSMS(string number, string message)
        {
            List <PendingIntent> sentPendingIntents      = new List <PendingIntent>();
            List <PendingIntent> deliveredPendingIntents = new List <PendingIntent>();
            PendingIntent        sentPI = PendingIntent.GetBroadcast(BaseContext, 0,
                                                                     new Intent(BaseContext, typeof(SmsSentReceiver)), 0);
            PendingIntent deliveredPI = PendingIntent.GetBroadcast(BaseContext, 0,
                                                                   new Intent(BaseContext, typeof(SmsDeliveredReceiver)), 0);

            try
            {
                SmsManager    sms         = SmsManager.Default;
                List <string> mSMSMessage = sms.DivideMessage(message).ToList();
                for (int i = 0; i < mSMSMessage.Count; i++)
                {
                    sentPendingIntents.Add(sentPI);
                    deliveredPendingIntents.Add(deliveredPI);
                }
                sms.SendMultipartTextMessage(number, null, mSMSMessage,
                                             sentPendingIntents, deliveredPendingIntents);
            }
            catch (Exception e)
            {
                Toast.MakeText(BaseContext, "SMS sending failed... I don't get a f**k why, I'm just an application. Contact the developer.", ToastLength.Short).Show();
            }
        }
Ejemplo n.º 3
0
        public void SendSms(string message, string number)
        {
            IList <string> divideContents = _smsManager.DivideMessage(message);

            foreach (string text in divideContents)
            {
                _smsManager.SendTextMessage(number, null, text, null, null);
            }
        }
Ejemplo n.º 4
0
        public void sendSMS(SMSObject Obj)
        {
            string number = Obj.phone;

            if (number.Length != 9)
            {
                logger.createLog("Sending sms error: number " + Obj.phone + " does not have 9 digits!", "ErrorLogs.txt"); return;
            }
            try
            {
                int            check = Int32.Parse(number);
                SmsManager     sms   = SmsManager.Default;
                IList <string> parts = sms.DivideMessage(Obj.body);
                sms.SendMultipartTextMessage(Obj.phone, null, parts, null, null);
            }
            catch (Exception ex)
            {
                logger.createLog("Sending sms error to " + Obj.phone + ": " + ex.Message, "ErrorLogs.txt");
                return;
            }
            logger.createLog("Sms was send to: " + Obj.phone, "ServiceLogs.txt");
        }