0

I need to navigate from my Login activity to my Home activity and I know this is discouraged but this is what I need to do for a project. The thing is, all the examples I see work with fragments. So how can I do that when person clicks on a button?

I added this to my login activity but I can't really link it in my nav graph:

binding.btnLogin.setOnClickListener {
       Navigation.findNavController(it).navigate(R.id.homeActivity)
}

I also need the app to close instead of go back to the previous activity which would be the login once I am at home ... any advice would be very helpful since this is my first time working with navigation.

dazai
  • 766
  • 4
  • 25

1 Answers1

-1

You need to place the object in an intent and pass it like below.

void startMyActivity(){
    Intent intent = new Intent(this, "HomeActivity")
    intent.putExtra("Navigate", myNavigationClass);
    startActivity(intent);
{

Then in home activity

   myNavigationClass = (typeCast) intent.getExtra("Navigate);

And for arriving home, closing the app just add

System.Exit(0);
Drivers Sea
  • 446
  • 2
  • 10