There is no (secure) way for an Activity to "chat" directly with another Activity. The way Android is architected, different Activities and Services can be in separate processes.
If you wanted to open the other Activity, firing an Intent would be the right way. But since you don’t want to, my suggestion is to record the value generated in Activity A in the app configuration:
SharedPreferences prefs;
prefs = PreferenceManager.
getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor ed = prefs.edit();
ed.putInt("numero", x);
ed.apply();
In Activity B you can read the configuration value:
SharedPreferences prefs;
prefs = PreferenceManager.
getDefaultSharedPreferences(getApplicationContext());
int x = prefs.getInt("numero", defaultx);
Actiivty B can also sign up to receive notifications when the setting is changed by Activity A:
prefs.registerOnSharedPreferenceChangeListener(this);
in this case your Activity should implement an interface, and the declaration looks like:
public class ActivityB extends Activity
implements SharedPreferences.OnSharedPreferenceChangeListener
and you must declare the method that will be called when any config changes:
public void onSharedPreferenceChanged(
SharedPreferences sharedPreferences, String key) {
if (key.equals("numero")) {
... numero mudou, atualizar o botao ....
}
}