Home > Mobile >  Between the Activity in the Android by value
Between the Activity in the Android by value

Time:10-02

If A interface to the B interface and pass the value received, I also want to have A value of the interface to the C and D interface but don't jump to page should to do, the search on the net are jump by value, it's no use ah

CodePudding user response:

Can be broadcast or broadcast,

CodePudding user response:

Demand is not very understand, C and D haven't open (i.e., also did not create an instance object) requires the value to preach in the past?

CodePudding user response:

EventBus

CodePudding user response:

If the interface is C and D in the stack, so long to use ordinary radio or EventBus ordinary events can, if it's not in the stack, it will need to use the sticky broadcast or EventBus viscous events

CodePudding user response:

You this needs no practical significance,

To the two did not open the activity by value is impossible,

May your business needs is not suitable for such value,

You can put the value stored in one place, and so on need to use the value activity starts, in the oncreate method to obtain the value of the file

CodePudding user response:

Ditto
C D within the stack, EventBus by value, not in the stack, C, D in A need to use the value of the saved to the SharedPreferences or file, C, D to use value/update the UI

CodePudding user response:

refer to 6th floor dear Joe reply:
you this needs no practical significance,

To the two did not open the activity by value is impossible,

May your business needs is not suitable for such value,

You can put the value stored in one place, and so on need to use the value activity starts, in oncreate method to get access to files stored value

C and D are open operation interface, but not by A interface to open, as if by A jump to B again by page jump to C B, but C interface of data in A interface, can be directly from A to C than A to B from B to C so trouble again

CodePudding user response:

refer to the eighth floor weixin_45297921 response:
Quote: refer to the sixth floor dear Joe reply:
you this needs no practical significance,

To the two did not open the activity by value is impossible,

May your business needs is not suitable for such value,

You can put the value stored in one place, and so on need to use the value activity starts, in oncreate method to get access to files stored value

C and D are open operation interface, but not by A interface to open, as if by A jump to B again by page jump to C B, but C interface of data in A interface, can be directly from A to C than A to B from B to C again bother?


There are several ways usually used:
Singleton class: the data saved to A singleton class, C and D starts by singleton class take data
2. SharePreference: suitable for save some small amount of persistent data,
3. Database: save a lot of persistent data
In general if you don't need data persistence, may be A way to use English more,
In addition to clear, from A to B, from B to C, and D it is recommended to do so in most cases, most of the time is the key of data transmission between pages and pages to get the data is acquired dynamically according to the key,

CodePudding user response:

The value is set to static, through the class to call

CodePudding user response:

EventBus, singleton, notice, want to preach you,

CodePudding user response:

EventBus is useful, especially when the value that is larger

CodePudding user response:

I have a stupid way, C and D is a static variables, so direct to assign values to C and D static variables for
  • Related