applicationDidEnterBackground

applicationDidEnterBackground

本文介绍了使用最新的Flurry SDK和ios4重新启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对最新版本的Flurry(Flurry iPhone SDK v2.5)感到沮丧。当我启动我的应用程序,快速退出,然后重新启动应用程序,应用程序短暂加载,闪烁黑屏,然后停留在黑屏上。黑屏停留在那里,直到我按下主页按钮,此时我可以正常重启应用程序。我进一步研究了这一点,结果发现app状态委托的命令顺序错误:

I have a frustrating problem with the latest version of Flurry (Flurry iPhone SDK v2.5). When I start my app, quickly exit, then restart the App, the app briefly loads, flickers a black screen, then stays on the black screen. The black screen stays there until I press the home button, at which point I can restart the app normally. I looked into this further, and it turns out that app state delegates are getting called in the wrong order:


  1. applicationDidBecomeActive // app完成加载第一次

  2. applicationWillResignActive // app开始辞职

  3. applicationWillEnterForeground //此时,我已经快速重启了应用程序,这就是

  4. applicationDidEnterBackground //当调用此委托时,屏幕变黑。

  5. applicationDidEnterBackground //当我再次按下主页按钮后调用屏幕已经挂了一段时间。

  1. applicationDidBecomeActive //app finishes loading the first time
  2. applicationWillResignActive //app begins to resign
  3. applicationWillEnterForeground //At this point, I have quickly restarted the app, and this is called
  4. applicationDidEnterBackground //When this delegate is called, the screen goes black
  5. applicationDidEnterBackground //This gets called when I hit the home button again, after the screen has been hanging for a while.

所以我认为这意味着一些过程需要更长时间才能结束按下主页按钮,如果我再次尝试再次启动应用程序,则会出现一些非常奇怪的行为。如果我等待几秒钟重启应用程序,应用程序就会正常运行。

So what I think this means is some processes take a bit longer to wrap up once I hit the home button, and if I try to start the app again too quickly there is some very odd behavior. If I wait a few seconds to restart the app, the app behaves normally.

为了演示这个问题,我创建了我能想到的最简单的应用程序,我将发布这里。我用XCode 3.2.3构建了这个,在4.0版本中直接在我的iphone设备(iphone 4)上。 这很重要,因为我无法在模拟器上重现此问题。您可以通过创建一个名为simpleApp的新导航项目并使用您自己的Flurry API密钥删除此代码来重现此应用程序当然。
这里是simpleAppAppDelegate.m:

To demonstrate this problem, I created the simplest app I could think of, which I will post here. I built this with XCode 3.2.3, in the 4.0 build directly onto my iphone device (iphone 4). This is important, because I couldn't reproduce this problem on the simulator. You can reproduce this app by creating a new navigation based project named simpleApp, and dropping this code in, with your own Flurry API key of course.Here is simpleAppAppDelegate.m:

#import "simpleAppAppDelegate.h"
#import "RootViewController.h"
#import "FlurryAPI.h"


@implementation simpleAppAppDelegate

@synthesize window;
@synthesize navigationController;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [FlurryAPI startSession:@"<your api key here>"];

    [window addSubview:navigationController.view];
    [window makeKeyAndVisible];

    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    printf("applicationWillResignActive\n");
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    printf("applicationDidEnterBackground\n");
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    printf("applicationWillEnterForeground\n");
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    printf("applicationDidBecomeActive\n");
}


- (void)applicationWillTerminate:(UIApplication *)application {
    printf("applicationWillTerminate\n");
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
}

- (void)dealloc {
    [navigationController release];
    [window release];
    [super dealloc];
}

@end

这里是simpleAppAppDelegate.h :

And here is simpleAppAppDelegate.h:

#import <UIKit/UIKit.h>

@interface simpleAppAppDelegate : NSObject <UIApplicationDelegate> {

    UIWindow *window;
    UINavigationController *navigationController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@end

所以无论如何,因为很多应用都在使用Flurry I我觉得我必须遗漏一些非常基本的东西。令我难以置信的是,我没有找到任何人抱怨这个特殊问题。 此外,这与先前版本中的应用程序似乎立即启动,黑色几秒钟,然后正常恢复的问题不同。通过调用[FlurryAPI setSessionReportsOnCloseEnabled:false]解决了这个问题;在我设置会话之后,但在这种情况下这没有帮助。

So anyway, because so many apps are using Flurry I feel like I must be missing something very basic. What really boggles my mind is that I haven't found anyone at all complaining about this particular problem. Also, this is different from the problem in previous versions where the app would appear to start immediately, go black for a few seconds, then resume normally. That problem was solved by calling [FlurryAPI setSessionReportsOnCloseEnabled:false]; after I set the session, but that doesn't help in this case.

无论如何,还有其他人有这个问题吗?我真的希望这对我来说只是一个愚蠢的错误。我真的很兴奋使用Flurry,但这样的事情会导致我的应用被拒绝。

Anyway, has anyone else had this problem? I really hope it's just a stupid error on my part. I'm really excited to use Flurry but something like this would cause my app to get rejected.

推荐答案

我写了关于这个的Flurry他们很快回到我身边,他们会调查这个。大约一个星期后,他们回信并表示他们已经在v2.6中修复了它,现在可用了。我似乎无法重现这个问题。

I wrote Flurry about this and they got back to me really quickly that they'd look into this. About a week later they wrote back and said they fixed it in v2.6 which is now available. I can't seem to reproduce the problem anymore.

不是说我很棒或者什么,但我还是单枪匹马地解决了这个问题。

Not to say I'm awesome or anything, but I did kind of single handedly fix this bug.

这篇关于使用最新的Flurry SDK和ios4重新启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 11:10