Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 05-12-2011, 04:42 PM   #1 (permalink)
iPhone Developer
 
alex5776's Avatar
 
Join Date: May 2011
Location: Minnesota
Age: 14
Posts: 26
alex5776 is on a distinguished road
Question Code in background

Hi!

I need some help with executing code in background.
It is not a location, sound, or voIP code.
I don't care if it gets rejected from the app store, i am making it for a friend.

so ya.

This is my code.

Code:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    SensorAutoLockAppDelegate *appDelegate = (SensorAutoLockAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    appDelegate.on = @"ON";
    if (appDelegate.on == @"ON") {
        UIDevice *device = [UIDevice currentDevice];
        device.proximityMonitoringEnabled = YES;
            NSLog(@"Searching");
    }else{
            NSLog(@"Not Searching");
    }
}
The below tells the app if a switch is on or off. I know it works.

Code:
SensorAutoLockAppDelegate *appDelegate = (SensorAutoLockAppDelegate *)[[UIApplication sharedApplication] delegate];
The below is turning on the proximity sensor.
Code:
UIDevice *device = [UIDevice currentDevice];
        device.proximityMonitoringEnabled = YES;
            NSLog(@"Searching");
    }else{
            NSLog(@"Not Searching");
    }
This app just puts the device into sleep mode when you put it into your pocket
__________________
-----------
Want to see me run to the apple store and back?
~~~Moments Later~~~
Want to see me do it again?
alex5776 is offline   Reply With Quote
Old 05-13-2011, 02:46 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

the app will work only for like 30 minutes, then the OS will kill it.
__________________
dany_dev is offline   Reply With Quote
Old 05-16-2011, 03:53 PM   #3 (permalink)
iPhone Developer
 
alex5776's Avatar
 
Join Date: May 2011
Location: Minnesota
Age: 14
Posts: 26
alex5776 is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
the app will work only for like 30 minutes, then the OS will kill it.
Thank you! But how will I get that?
__________________
-----------
Want to see me run to the apple store and back?
~~~Moments Later~~~
Want to see me do it again?
alex5776 is offline   Reply With Quote
Old 05-16-2011, 04:35 PM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Quote:
Originally Posted by alex5776 View Post
Thank you! But how will I get that?
see Completing a Finite-Length Task in the Background
__________________
dany_dev is offline   Reply With Quote
Reply

Bookmarks

Tags
background application, code, proximity, sensor, sleep

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 418
11 members and 407 guests
AppleDev, chemistry, Emy, Gi-lo, ipodphone, mistergreen2011, pipposanta, QuantumDoja, Retouchable, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,924
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0