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.
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);
lock.disableKeyguard();