Android应用程序对象 [英] android application object
问题描述
我看了一下android的现场应用对象,但我不明白。
I have read about application object in android site but I couldn't understand.
什么是应用对象的Android?
什么是使用应用程序对象的
当我们要使用的应用程序对象
What is application object android?
What is the use of application object
When we should use application object
请用例子来说明。
感谢你。
推荐答案
Application对象是一个对象,其生命周期是一样的我们的应用程序。
当应用程序启动这个目的是通过Android框架自动创建。
When Application starts this object is created automatically by Android Framework.
当你想你的应用程序的多个活动之间共享数据,或者你想留住的东西在申请level.In的情况下,您可以使用Application对象为您的应用程序的全局商店。
例::
// this is your Application Object Class
public class MyApplication extends Application{
}
在你的清单中提到它,如下所示::
In your manifest mention it as follows::
<application android:name="yourpkgname.MyApplication"/>
要访问的应用程序对象中的任何activities.Use以下code。
To access application object in any of the activities.Use the following code.
MyApplication app = (MyApplication) getApplication();
我觉得这是很不够的,你抢的应用对象的概念。
I think this is quite enough for you to grab the concept of application object.
这篇关于Android应用程序对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!