Android Central African activity class method call activity

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()

 

Guess you like

Origin www.cnblogs.com/ken9527just/p/11539582.html