I am creating a Lock Replacement application which obviously requires it to have an activity that starts the ACTION_SCREEN_ON is called. These are the portions of my code relevant to it:
public class StartupBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent startupIntent = new Intent(context, Lockdown.class); // substitute with your launcher class
startupIntent.addCategory(Intent.CATEGORY_HOME);
startupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(startupIntent);
}
}
Since ACTION_SCREEN_ON cannot be called from the Manifest I registered it dynamically in my main activity.
This is in my onCreate function of my main class (Lockdown)
IntentFilter filter = new IntentFilter (Intent.ACTION_SCREEN_ON);
BroadcastReceiver mReceiver = new StartupBroadcastReceiver();
registerReceiver(mReceiver, filter);
Any help is highly appreciated. Thanks in advanced