1

In the application,I am trying to a make activity show when user opens the screen lock (screen unlock) and when activity finish user open screen lock activity run back.I am trying

Intent.ACTION_SCREEN_ON

but it is not working properly. And I also used

USER_PRESENT

but I am not able get expected answer

I tried to find on google but was unsuccessful ,so I am confused how to make this type please tell me fast.

Joel Etherton
  • 37,325
  • 10
  • 89
  • 104
urveshpatel50
  • 1,675
  • 16
  • 35
  • you can register ACTION_SCREEN_ON only using a registerReceiver(): http://stackoverflow.com/questions/1588061/android-how-to-receive-broadcast-intents-action-screen-on-off so you can try to build service which starts on boot: http://www.androidcompetencycenter.com/2009/06/start-service-at-boot/ and try to registerReceiver there – Selvin Nov 09 '11 at 11:45
  • but i am not any message like service created, service destroy .please tell me fast – urveshpatel50 Nov 09 '11 at 12:26
  • "please tell me fast" it's an order? i provide all information you needed ... i just build such thing ... but it's so annoying that i'll not tell you how exaclly do this – Selvin Nov 09 '11 at 12:29
  • "but i am not any message like service created, service destroy" becouse u need to boot ... try this on real device ... add registerReciver in onStart of this service ... – Selvin Nov 09 '11 at 12:38

1 Answers1

1

What version of Android are you targeting?

I have been able to get USER_PRESENT working fine on 2.x devices, by declaring it in the manifest.

On 3.x & 4.x I was unable to get it working at first. On these later versions you need to run the activity at least once before the system will allow you to register for the event. This is not needed in 2.x.

I have succeeded with this on 2.x, 3.x and 4.x devices and it works. A simple option for an activity to run, if your app is a background app, is a welcome screen with configuration options on it. This would not be out of place in a background app, and satisfies the conditions.

Community
  • 1
  • 1
Richard Le Mesurier
  • 29,432
  • 22
  • 140
  • 255