Telephone, iphone and big bad idleTimerDisabled

read a lot about how to prevent iphone that will sleep when working with my application. I am very unhappy at the moment because nothing is working.

here I read the idea of ​​creating a timer every 30 seconds to set idleTimerDisabled to NO and then YES, but my objC is not so good though. can someone tell me how (and where)?

Thnx!

edit: here is the code I tried:

- (void)applicationDidFinishLaunching:(UIApplication *)application
{   
    [ super applicationDidFinishLaunching:application ];
    //application.idleTimerDisabled = NO;
    //application.idleTimerDisabled = YES;
    //[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    [UIApplication sharedApplication].idleTimerDisabled = NO;
    [UIApplication sharedApplication].idleTimerDisabled = YES;


}

edit2: after that I tried to run the loop with

-(void)_timerLoop
{
    // add this function up the top.  it what will happen when the
    // timer goes off:
    NSLog(@"Your timer went off!!!");
}


/**
 * This is main kick off after the app inits, the views and Settings are setup here.
 */
- (void)applicationDidFinishLaunching:(UIApplication *)application
{   
    [ super applicationDidFinishLaunching:application ];
    //application.idleTimerDisabled = NO;
    //application.idleTimerDisabled = YES;
    //[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    //[UIApplication sharedApplication].idleTimerDisabled = NO;
    //[UIApplication sharedApplication].idleTimerDisabled = YES;
    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(_timerLoop) userInfo:nil repeats:YES];


}

edit3: you really can't accidentally change descending points? would be a good chanage request for a stackoverflow system!

+3
source share
2 answers

:

( ) 30 :

-(void)_jump
{
// add this function up the top.  it what will happen when the
// timer goes off:
NSLog(@"Your timer went off!!!");
}
...
// here how to create the timer, which will go off in 30 seconds
[NSTimer scheduledTimerWithTimeInterval:30.0
   target:self selector:@selector(_jump) userInfo:nil repeats:NO]

, 30, 60 , . , !


. :

application.idleTimerDisabled = YES;

"application doneFinishLaunchingWithOptions".

.m..

"return YES;" - ! , :

-(BOOL)application:(UIApplication *)application
            didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    // blah blah ...

    application.idleTimerDisabled = YES;
    return YES;
    }
+3

[UIApplication sharedApplication].idleTimerDisabled = YES;

  • (BOOL) : (UIApplication *) didFinishLaunchingWithOptions: (NSDictionary *) launchOptions

. . , , phonegap, , idleTimerDisable NO . :

[UIApplication sharedApplication].idleTimerDisabled = YES;

, , .

+1

All Articles