Hi, I can't seem to get ACTION_SCREEN_OFF/ON to work.

I am registering them from java rather than the manifest (by the way
the quality of the documentation is getting tiresome). Do I need some
permissions to receive this. My code is as follows. The service is
definitely started and continues to run while the screen is turned on
and off.

public class FlashService extends Service
{
        private Receiver receiver = new Receiver();

        @Override
        public IBinder onBind(Intent intent)
        {
                return null;
        }

        @Override
        public void onStart(Intent intent, int startId)
        {
                Log.d("****** ", "FlashService.onStart()");
                registerReceiver(receiver, new IntentFilter
(Intent.ACTION_SCREEN_ON));
                registerReceiver(receiver, new IntentFilter
(Intent.ACTION_SCREEN_OFF));
        }

        @Override
        public void onDestroy()
        {
                Log.d("****** ", "FlashService.onDestroy()");
                unregisterReceiver(receiver);
        }

        public class Receiver extends BroadcastReceiver
        {
                @Override
                public void onReceive(Context context, Intent intent)
                {
                        Log.d("****** ", "Receiver.onReceive()");
                }
        }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to