コード例 #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();
    }
  }