Take the 2-minute tour ×

I want to develop an application that triggers up automatically when the user pulls out the earphones. I would like to know if it is possible to run it in the foreground automatically avoiding the unlock screen.

Thank you in advance.

share|improve this question
It's definitely not possible unless you jailbreak. I don't know how easy it is if you jailbreak. –  rob mayoff Feb 20 '12 at 7:28
Since jailbreak is not an option I suppose that there is no other way. Thank you for your reply. –  daunmi Feb 20 '12 at 7:58

2 Answers 2

up vote -1 down vote accepted

You may run in background if you build a Service. Also, you may intercept the SCREEN_ON or SCREEN_OFF event (look for a BrodcasrReciever to see how to use it). Use that events to execute your code. And to disable your lockscreen.... it's simple:

KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE); 
    KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
share|improve this answer
Provided solution is applicable to Android (not to iOS). –  Victor Ronin Jul 19 '12 at 21:56

There's no way to do this using the standard APIs. Certain apps can run in the background, but only if they do certain very specific tasks (e.g., apps that play audio or use GPS for navigation). But even if you did that, you can't do any of these things programatically: 1. disable the lock screen 2. detect when the phone has been locked 3. bring your app to the foreground.

share|improve this answer

Your Answer


