There is a click listener, it runs void
send1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mm(); try { main1(); } catch (LoginException e) { e.printStackTrace(); } catch (NoSuchPaddingException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (InvalidKeyException e) { e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } catch (IllegalBlockSizeException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } }); For clarity, I display toasts; when I click, mm () outputs toasts and main1 () does not. Main code
String test = textSend.getText().toString(); Cipher cipher2 = Cipher.getInstance("RSA"); cipher2.init(Cipher.ENCRYPT_MODE, originalPublicKey); byte[] bytes2 = cipher2.doFinal(test.getBytes()); Cipher decript2 = Cipher.getInstance("RSA"); decript2.init(Cipher.DECRYPT_MODE,originalPrivateKey); byte[] decriptedBytes2 = decript2.doFinal(bytes2); for (byte b : decriptedBytes2)kodMess+=(char) b; Toast.makeText(ChatActivity.this, "kodMess", Toast.LENGTH_SHORT).show(); If you put a toast at the beginning, then it will work, if at the end, no. What could be the reason?
Exception. Which one and which line - see in Logcat - woesss