Screen off and on in android/Program that listens screen off in android/listening to screen on and off in android package com.sample; import android.app.Service; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.IBinder; public class ScreenAction extends Service{ @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null ; } @Override public void onCreate() { // TODO Auto-generated method stub super .onCreate(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { // TODO Auto-generated method stub IntentFilter filter = new IntentFilter(Intent. ACTION_SCREEN_OFF ); filter.addAction(Intent. ACTION_USER_PRESENT ); registerReceiver( mReceiver , fil
If you are a beginner , then this blog will help you to dive into the basics.