我有一项服务,我可以从该服务中恢复我的ScreenReceiver
班级。触发OnRecieve
方法时如何通知服务?ScreenReceiver
我希望在update()
触发“onRecieve”时调用该方法。
StateChecker.java(草案):
public class StateChecker extends Service {
//...
// setting TimeAlarm
TimeAlarm mTimeAlarm = new TimeAlarm();
mTimeAlarm.SetAlarm(this.getApplicationContext(),10);
public void update() {
//update sth
}
//...
}
ScreenReceiver.java(草稿):
public class ScreenReceiver extends BroadcastReceiver {
//...
@Override
public void onReceive(Context context, Intent intent) {
//...
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
}
//...
}