Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1.  
  2. import android.content.Context;
  3. import android.net.ConnectivityManager;
  4. import android.net.NetworkInfo;
  5. import android.widget.Toast;
  6.  
  7. import static android.content.Context.CONNECTIVITY_SERVICE;
  8.  
  9. public class Util {
  10.  
  11.  
  12. public static boolean verificarInternet(Context context) {
  13. ConnectivityManager conexao = (ConnectivityManager) context.getSystemService(CONNECTIVITY_SERVICE);
  14. NetworkInfo infoRede = conexao.getActiveNetworkInfo();
  15.  
  16. if (infoRede != null && infoRede.isConnected())
  17. return true;
  18. else
  19. return false;
  20. }
  21.  
  22. public static void opcoesErro(Context context, String resposta) {
  23. if (resposta.contains("least 6 characters")) {
  24. Toast.makeText(context, "A senha deve ter ao menos 6 caracteres.", Toast.LENGTH_LONG).show();
  25. } else if (resposta.contains("address is badly")) {
  26. Toast.makeText(context, "Endereço de email inválido.", Toast.LENGTH_LONG).show();
  27. } else if (resposta.contains("interrupted connection")) {
  28. Toast.makeText(context, "Sem conexão com o Firebase.", Toast.LENGTH_LONG).show();
  29. } else if (resposta.contains("There is no user")) {
  30. Toast.makeText(context, "Email não cadastrado.", Toast.LENGTH_LONG).show();
  31. } else if (resposta.contains("password is invalid")) {
  32. Toast.makeText(context, "Senha inválida.", Toast.LENGTH_LONG).show();
  33. } else if (resposta.contains("address is already")) {
  34. Toast.makeText(context, "Email já existe na base de dados.", Toast.LENGTH_LONG).show();
  35. } else {
  36. Toast.makeText(context, resposta, Toast.LENGTH_LONG).show();
  37. }
  38. }
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement