For example, you would use:
Alarm Manager = (Alarm Manager) getSystemService (ALARM_SERVICE);
The first method is that it becomes a class Activity.
The second method is to pass the context Context. as follows:
1 alarmManager = (AlarmManager) mContext.getSystemService(ALARM_SERVICE);
The second approach may avoid the following errors:
java.lang.IllegalStateException: System services not available to Activities before onCreate()