Android中的Extends Application和Extends Activity有什么区别? [英] What is the difference between Extends Application and Extends Activity in Android?

查看:132
本文介绍了Android中的Extends Application和Extends Activity有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对两者之间的区别感到困惑。在我的应用程序中,我刚刚使用了Extends Activity,应用程序运行正常,那么Extends Application的目的是什么?

I am confused as to the difference between the two. In my application I have just used Extends Activity and the application is working perfectly, so what is the purpose of Extends Application?.

您是否会在Android应用程序中创建的第一个课程中使用它?

Would you use it on the first class you create in the Android application?

谢谢。

推荐答案

android.app.Application类是一个用于扩展和存储应用程序全局状态的可选工具。还有其他方法可以做到这一点,因此大多数应用程序都不会自定义此类。

The android.app.Application class is an optional facility for extending and storing application-global state. There are other ways of doing this, so most apps don't customize this class.

然而,活动定义了应用程序的每个主要阶段。没有活动就无法构建应用程序。你将有一个主要的Activity类,这确实会用'extends Activity'定义。

Activities however are what defines every major stage of your application. It wouldn't be possible to build an application without Activities. You will have a main Activity class and this will indeed be defined with 'extends Activity'.

这篇关于Android中的Extends Application和Extends Activity有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆