-1

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.

VISHAL DAGA
  • 4,132
  • 10
  • 47
  • 53

1 Answers1

1

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.

PravinCG
  • 7,688
  • 3
  • 30
  • 55
  • you are correct, actually I don't know why when the phone is locked and a particular sms is received, the first activity is called correctly but the second activity (the location listener) which is called (for result) by the first activity, performs the code in the onPause() case and that is why the SMS is not sended. – VISHAL DAGA Dec 10 '11 at 08:08
  • The problem is I think I am using activity instead of service which does the work of sensing location. Is there any way to overcome this problem without resorting to use service as its would be a lot of hard job to remove the activity and use service for the job in the application. – VISHAL DAGA Dec 10 '11 at 08:18
  • You have to use IntentService. – PravinCG Dec 10 '11 at 08:44