示例代码:

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSLog(@"%@",NSStringFromSelector(_cmd));//_cmd是iOS内置的参数可以直接打印当前的方法名
return YES;
} - (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
NSLog(@"%@",NSStringFromSelector(_cmd));
} - (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
NSLog(@"%@",NSStringFromSelector(_cmd));
} - (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
NSLog(@"%@",NSStringFromSelector(_cmd));
} - (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
NSLog(@"%@",NSStringFromSelector(_cmd));
} - (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
NSLog(@"%@",NSStringFromSelector(_cmd));
} @end

1.首次运行打印出来的消息是:

2016-06-30 17:17:19.610 测试状态改变[53450:338456] application:didFinishLaunchingWithOptions:

2016-06-30 17:17:19.613 测试状态改变[53450:338456] applicationDidBecomeActive:

2.程序切换到后台时,打印出来的消息是:

2016-06-30 17:17:24.516 测试状态改变[53450:338456] applicationWillResignActive:

2016-06-30 17:17:25.096 测试状态改变[53450:338456] applicationDidEnterBackground:

3.程序从后台切换到前台时,打印出来的消息是:

2016-06-30 17:19:18.335 测试状态改变[53450:338456] applicationWillEnterForeground:

2016-06-30 17:19:18.849 测试状态改变[53450:338456] applicationDidBecomeActive:

4.程序终止时,并不会执行  applicationWillTerminate:这个方法,而是直接报错。

测试App运行状态的更多相关文章

  1. Fiddler抓包测试App接口

    Fiddler抓包测试App接口 使用Fiddler对手机App应用进行抓包,可以对App接口进行测试,也可以了解App传输中流量使用及请求响应情况,从而测试数据传输过程中流量使用的是否合理. 抓包过 ...

  2. OSX10.12搭建IPv6本地环境测试APP

    前记 最近刚换了工作,生活终于又安定下来了,又可以更博了 正文 最近公司在上线APP(整体全是用JS去写的,就用了我原生的一个控制器),然后APP就去上线,就被苹果巴巴给拒了.通过阅读苹果回复的邮件, ...

  3. iPhone手机获取uuid 安装测试app

    iPhone手机获取uuid 安装测试app UDID是一种iOS设备的特殊识别码.除序号之外,每台ios装置都另有一组独一无二的号码,我们就称之为识别码( Unique Device Identif ...

  4. 【转】iPhone手机获取uuid 安装测试app

    iPhone手机获取uuid 安装测试app UDID是一种iOS设备的特殊识别码.除序号之外,每台ios装置都另有一组独一无二的号码,我们就称之为识别码( Unique Device Identif ...

  5. 不同地区Android开发者使用哪些设备测试APP?

    我们的团队密切关注着移动世界的趋势,以便可以提供所有有关变化的最紧密和最重要的信息.春天恰好是对app进行新一轮测试并检查其与不同Android设备兼容性如何的最佳时机.下面让我们一起来看看全世界范围 ...

  6. 专项测试-App性能分析

    专项测试 app性能 Activity是Android组件中最基本也是最为常见用的四大组件(Activity,Service服务,Content Provider内容提供者,BroadcastRece ...

  7. iOS 真机测试 App installation failed

    真机测试的过程中,出现这种Bug This application's application-identifier entitlement does not match that of the in ...

  8. android安全测试 APP要点解析

    评估思路 移动APP面临的威胁 风起云涌的高科技时代,随着智能手机和iPad等移动终端设备的普及,人们逐渐习惯了使用应用客户端上网的方式,而智能终端的普及不仅推动了移动互联网的发展,也带来了移动应用的 ...

  9. Appium+python测试app实例

    Appium和selenium差不到,只是一个用于测web,一个用于测APP.下面记录一下我搭的测试框架,同样是基于PO模式,用的unittest. 最后测试报告如下: 1.1      代码结构 这 ...

随机推荐

  1. linux消息队列的使用及内核实现原理

    mq_receive NAME mq_open - open a message queue SYNOPSIS #include <fcntl.h> /* For O_* constant ...

  2. Types of compression algorithms

    http://www.html5rocks.com/en/tutorials/speed/img-compression/ Types of compression algorithms There ...

  3. toast 防止一直不停弹出,累积显示

    private Toast mToast = null; public void showTextToast(String msg) { if (mToast == null) { mToast = ...

  4. Java 特殊性领会

    1. 字符串比较绝对不能用 == 而必须是 xx.equals() 2. 多有对象new 后都是以引用的方式存在着 3. 数组list, map 类型都不能边用for 循环边删除,迭代器可以 eg: ...

  5. CSS的display属性,显示或隐藏元素

    <html> <head> <script type="text/javascript"> function removeElement() { ...

  6. git-svn

    sudo apt-get install git-svn svn作为一个优秀源码版本的管理工具,可以适合绝大多数项目.但是因为它的采用中心化管理,不可避免的存在本地代码的备份和版本管理问题.也就是说对 ...

  7. 国外it网站收集

    1.http://news.com.com/2.http://www.zdnet.com/3.http://www.salon.com/tech/index.html4.http://www.brin ...

  8. github中国版本coding.net 的部署和使用

    1.在coding.net注册帐号. 2.安装github,自己百度github软件然后安装. 3.打开coding.net 输入帐号后新建项目 创建项目 创建后,创建ssh公钥,如果不创建的话,在每 ...

  9. C#中string.Empty ,"" , null 区别

    引言 String类型作为使用最频繁的类型之一,相信大家都非常熟悉,对于string赋予空值,通常有以下三种方式: String str1=null; String str2=””; String s ...

  10. jQuery插件之Wookmark瀑布流

    使用方法: 1.下载wookmark.js 2.构建html <div class="wrapper"> <div id="con1_1"&g ...