android: send & get String besides by using extra(

2020-04-16 03:34发布

问题:

I just wonder what method can be use to send String from one to another activity besides by using intent.putExtra(), and getIntent.getExtra(). Cause my project getting unexpected result when using putExtra(), just want to another for send String.

Any suggestion and examples? Thanks.

回答1:

you can also send by following ways

How do I pass data between Activities/Services within a single application?

Non-Persistent Objects

For sharing complex non-persistent user-defined objects for short duration, the following approaches are recommended:

  • Singleton class - Ref Here:

  • A public static field/method

  • A HashMap of WeakReferences to Objects