Search code examples
androidbundleglobal-state

How to send variables from Main activity to multiple activities in android?


Iam trying to create an application that have

  1. MainActivity
    it is a login page , it contain 4 variable, when i click the login button, it goes to another activity HomeTab using an intent
    Intent i = new Intent(FirstMain.this,Home_tab.class);
    startActivity(i);

  2. HomeTab - it has three Tab views.
    a. Profile
    b. Account
    c. Settings

My problem is how to pass that 4 variables from the MainActivity to the 3 activities in the Tab


Solution

  • you have two options.

    1. you can use intent.
    2. you can use sharedpreferences.