更新时间:2022-12-29 14:53:46
创建扩展应用程序的类并保持实例那里。
Create a class that extends Application and hold the instance there.
class MyApp extends Application{
private Object obj;
public Object getObject(){
return obj;
}
}
然后在你的活动
MyApp ma = (MyApp)getApplicationContext();
Object o = ma.getObject();
您可以阅读更多关于Android开发者网站上的应用程序类:http://developer.android.com/reference/android/app/Application.html
You can read more about the Application class on the android developer website: http://developer.android.com/reference/android/app/Application.html