My application don't have any user interaction. I need to run some code when the phone goes to the SCREEN OFF
or SCREEN ON
state.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.testing"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver android:name=".ChekingReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.SCREEN_OFF" />
<action android:name="android.intent.SCREEN_ON" />
<action android:name="android.intent.action.SCREEN_OFF" />
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver>
</application>
My receiver class
public class ChekingReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
System.out.println("received :"+intent.getAction());
}
}
But this is not working.Can Anybody find the mistake i am doing here ?