0

我想在活动开始时在一项活动中获取所有数据,然后在所有其他活动中使用该数据。比如获取所有用户信息、电话中的所有联系人并将其与服务器数据进行比较等。那么有人可以帮助我吗?提前致谢。

4

1 回答 1

1

You can extend the Application class in android. It is a singleton class, so whatever value you set there, can be accessed from another activity.

You can access ur application instance like this in every activity

MyApplication appContext = (MyApplication)getApplicationContext();

And inside the manifest file add the attribute to the application tag

android:name=".MyApplication"
于 2012-06-27T06:57:03.777 回答