Example #1
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btn_enviar:
       try {
         if (etxt_destinatario.length() == 0
             || Integer.parseInt(etxt_nota.getText().toString()) > 3
             || etxt_mensaje.length() == 0) {
           Toast.makeText(NuevoObjeto.this, R.string.msgerror, Toast.LENGTH_SHORT).show();
         } else {
           // AQUI LO CONVIERTE
           Intent i = new Intent();
           i.putExtra("emisor", txt_useremisor.getText().toString());
           i.putExtra("destinatario", etxt_destinatario.getText().toString());
           i.putExtra("nota", Integer.parseInt(etxt_nota.getText().toString()));
           i.putExtra("mensaje", etxt_mensaje.getText().toString());
           setResult(RESULT_OK, i);
           finish();
           break;
         }
       } catch (java.lang.NumberFormatException e) {
         Toast.makeText(NuevoObjeto.this, e.getMessage(), Toast.LENGTH_SHORT).show();
       }
       // FORMA QUE NO FUNCIONA
       /*Objeto nuevo_objeto = new Objeto(txt_useremisor.getText().toString(),
       etxt_destinatario.getText().toString(),
       Integer.parseInt(etxt_nota.getText().toString()),
       etxt_mensaje.getText().toString());
       i.putExtra("NuevoObjeto", nuevo_objeto);*/
       // startActivityForResult(i,1);
   }
 }
Example #2
0
  private BackupFolder getBackupFolder(String label) throws MessagingException {
    if (label == null) throw new IllegalStateException("label is null");

    try {
      BackupFolder folder = new BackupFolder(this, label);

      if (!folder.exists()) {
        folder.create(FolderType.HOLDS_MESSAGES);
        Log.i(TAG, "Label '" + label + "' does not exist yet. Creating.");
      }
      folder.open(OpenMode.READ_WRITE);
      return folder;
    } catch (java.lang.NumberFormatException e) {
      // thrown inside K9
      Log.e(TAG, "K9 error", e);
      throw new MessagingException(e.getMessage());
    }
  }
Example #3
0
 static void init(String host, String portStr) {
   Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
   BasicConfigurator.configure(root.getLoggerContext());
   try {
     int port = Integer.parseInt(portStr);
     logger.info("Creating socket appender (" + host + "," + port + ").");
     s = new SocketAppender();
     s.setRemoteHost(host);
     s.setPort(port);
     s.setName("S");
     root.addAppender(s);
   } catch (java.lang.NumberFormatException e) {
     e.printStackTrace();
     usage("Could not interpret port number [" + portStr + "].");
   } catch (Exception e) {
     System.err.println("Could not start!");
     e.printStackTrace();
     System.exit(1);
   }
 }
 public EncryptionKeys(
     @Nullable String adminKey, @Nullable String memberKey, @Nullable String guestKey) {
   _adminKey = getKeyFromString(adminKey);
   _memberKey = getKeyFromString(memberKey);
   _guestKey = getKeyFromString(guestKey);
   _adminKeyBytes = null;
   _memberKeyBytes = null;
   _guestKeyBytes = null;
   try {
     if (_adminKey != null) {
       _adminKeyBytes = BleUtils.hexStringToBytes(_adminKey);
     }
     if (_memberKey != null) {
       _memberKeyBytes = BleUtils.hexStringToBytes(_memberKey);
     }
     if (_guestKey != null) {
       _guestKeyBytes = BleUtils.hexStringToBytes(_guestKey);
     }
   } catch (java.lang.NumberFormatException e) {
     BleLog.getInstance().LOGe(TAG, "Invalid key format");
     e.printStackTrace();
   }
 }