Create separate method for calling activity



  • I created a script where I intend to call separate activities

    but it's not working

    package com.example.john.new_login;
    

    import android.content. Context; import android. content. Intent;

    import with.example. john. new_login.login. Registration; import with.example. john. new_login.login. Back Password;

    ** * Created by John on 09/12/2017. ♪

    public class Botoes_Login {

    private static Context context;
    

    public static void Registro() {
    Intent registro = new Intent(context, Cadastro.class);
    context.startActivity(registro);
    }

    public static void RecuperaSenha() {
    Intent recuperasenha = new Intent(context, RecuperaSenha.class);
    context.startActivity(recuperasenha);
    }

    public static void Login() {
    Intent login = new Intent(context, Login.class);
    context.startActivity(login);
    }

    )

    How would it be the right way to create a class for that?



  • Let me get this straight.

    You have created a ChamarActivities class with some methods. Ai do you want to give, for example, CallActivities.Login() to the method already make the transition from Activities? If yes, I think your script already works, you should only, before calling the method, fill the context attribute with the context of the current screen. But I recommend taking this static attribute and passing the context by parameter.

    Ex:

    ChamarActivities.Login(MainActivity.this);
    

    If what I said doesn't help, I think it's making some other mistake, what would it be?




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2