Application类的作用

在Application类的实现类中,无非就是做一些初始化程序数据、检查运行环境、销毁数据等。1、初始化程序数据: 常用的初始化的手段有创建程序所需要的目录,设置开发平台的key,初始化地图信息,初始化http或者其他和网络有关的东西,初始化推送等等。
2、检查运行环境 比如检查是否存在sd卡、判断网络连接状况、检查内存等等。
3、销毁数据 就是在onTerminate()方法里面销毁之前使用到的一些东西。说到onTerminate()这个方法,在官方文档中是这样说的,This method is for use in emulated process environments. It will never be called on a production Android device, where processes are removed by simply killing them; no user code (including this callback) is executed when doing so. 它是在模拟环境下调用的,在真机中永远不会被调用。那为什么那么多app的Application类都用到这个方法呢?

原文地址:https://www.cnblogs.com/tiandee/p/4401696.html