Create separate method to call activity

0

I created a script where I intend to call separate activities

But it is not working

package com.example.john.new_login;

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

import com.example.john.new_login.login.Cadastro; import com.example.john.new_login.login.RecuperaSenha;

/ **  * Created by John on 12/09/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);
}

}

What would be the correct way to create a class for this?

    
asked by anonymous 09.12.2017 / 21:01

1 answer

0

Let me get this straight.

You have created a ChamarActivities class with some methods. Are you planning to give, for example, ChamarActivities.Login () to the method already making the transition from Activities? If yes, I believe that your script already works, you should only, before calling the method, fill in the context attribute with the context of the current screen. But I recommend you take this static attribute and pass the context by parameter.

Ex:

ChamarActivities.Login(MainActivity.this);

If what I said does not help, I think it is giving some other error, what would it be?

    
09.12.2017 / 21:48