Ejemplo n.º 1
0
  // obsługa przycisku zatwierdz
  public void sendSmsByManager() {
    try {

      smsModel.setPhone(phoneNumber.getText().toString());
      smsModel.setSms(smsBody.getText().toString() + " ");
      dateTextView.setText("");
      timeTextView.setText("");
      phoneNumber.setText("");
      smsBody.setText("");
      if (Patterns.PHONE.matcher(smsModel.getPhone()).matches()) {
        Message msg = Message.obtain(null, SMSService.SEND_SMS, 0, 0);
        Bundle bundle = new Bundle();
        bundle.putParcelable("sms", smsModel);
        msg.setData(bundle);
        try {
          messenger.send(msg);
        } catch (RemoteException e) {
          e.printStackTrace();
        }
      } else {
        Toast.makeText(getApplicationContext(), R.string.invalidPhone, Toast.LENGTH_LONG).show();
      }

    } catch (Exception ex) {
      Toast.makeText(getApplicationContext(), R.string.failedToSendSms, Toast.LENGTH_LONG).show();
      ex.printStackTrace();
    }
  }
Ejemplo n.º 2
0
 public static boolean isValidPhoneNumber(CharSequence phoneNumber) {
   if (!TextUtils.isEmpty(phoneNumber)) {
     return Patterns.PHONE.matcher(phoneNumber).matches();
   }
   return false;
 }
Ejemplo n.º 3
0
 public boolean validCellPhone(String number) {
   return android.util.Patterns.PHONE.matcher(number).matches();
 }