Sharing an object between activities

前端 未结 2 1084
旧时难觅i
旧时难觅i 2021-01-02 14:53

I have a Weather app with four Activities. The main/launcher activity is \'invisible\' using...

android:theme=\"@android:style/Theme.Translucent.NoTitleBar\"`

<
相关标签:
2条回答
  • 2021-01-02 15:39

    Well, your question has been answered, but it seems like it would be much simpler to instantiate your WeatherHelper object in the onCreate() of the Activity that has the launcher intent, and make the WeatherHelper static.

    0 讨论(0)
  • 2021-01-02 15:43

    I would store shared information in you Application object. Subclass this and add any extra initialization and data there. You can get your application using getApplication() from your activity, which you can cast to your specialized version and access the shared data.

    I would also avoid launching the special startup activity if possible and do the work in your Application's onCreate() override.

    0 讨论(0)
提交回复
热议问题