I am making an application which will do something on receipt of a particular SMS and after doing that something it will send an SMS back. Everything is fine but the SMS sending service is not working when there is some keyguard lock or any other lock. I need to disable all locks and then send SMS and then again lock the phone. How is it to be done. I had tried with

 mKeyGuardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
 mLock = mKeyGuardManager.newKeyguardLock("Locationlistener");
 mLock.disableKeyguard();

and then tried to reenable with

 mKeyGuardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
 mLock = mKeyGuardManager.newKeyguardLock("Locationlistener");
 mLock.reenableKeyguard();

but its unlocking the keyguard and then the keyguard never appear again. It is also not working for pattern lock.

有帮助吗?

解决方案

What has keyguard lock to do with SMS sending? You need to have the correct permission for your application and you can send the SMS irrespective. I have not encountered such an issue in my application which works solely on SMS command.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top