I have code below that I have inserted into my onCreate method, but it dosent seem to work. I want it to launch other activity when screen goes off/battery button press.
CODE:
protected void onStartCommand() {
// TODO Auto-generated method stub
super.onStart();
ScreenReceiver();
}
public class ScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
lock.reenableKeyguard();
Intent s = new Intent(Activity1.this , Activity2.class);
startActivity(s);
}
else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
lock.disableKeyguard();
}
}
}
Any help would be VERY appreciated?