ScreenOnOffBroadCast.java
2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.lotus.town.broadcast;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import com.controller.NotifyType;
import com.lotus.town.ali.MonitorService;
import com.lotus.town.config.SupportAction;
import com.lotus.town.locker.LockerActivity;
import com.lotus.town.notify.NotifyManager;
import com.sdk.Debug;
import com.sdk.EventBus;
import com.sdk.SharedPref;
public class ScreenOnOffBroadCast extends BroadcastReceiver{
private final String TAG = "secln.ScreenOnOffBroadCast";
@Override
public void onReceive(final Context context, Intent intent) {
if(intent.getAction().equals("android.intent.action.SCREEN_OFF")|| intent.getAction().equals(SupportAction.SCREEN_OFF_MY)){
SharedPref.getOrSetEvFlag(context,false,false);
NotifyManager.NotifyChange(context, NotifyType.SCREEN_OFF_NOTIRY);
} else if(intent.getAction().equals("android.intent.action.SCREEN_ON")){
MonitorService.invoke(context);
NotifyManager.NotifyChange(context,NotifyType.SCREEN_ON_NOTIRY);
EventBus.getInstance().notify(EventBus.SCREEN_ON);
} else if(intent.getAction().equals("android.intent.action.USER_PRESENT")){
SharedPref.increateUnlockScreen(context);
NotifyManager.NotifyChange(context,NotifyType.UNLOCK_NOTIRY);
} else if(intent.getAction().equals("android.intent.action.TIME_TICK")){
MonitorService.invoke(context);
} else if(intent.getAction().equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)){
if(Debug.DEBUG_MODE){
Toast.makeText(context,"ACTION_CLOSE_SYSTEM_DIALOGS",Toast.LENGTH_SHORT).show();
}
String reason = intent.getStringExtra( "reason" );
if(reason != null) {
if (reason.equals("homekey")) {
LockerActivity.startActivitySelf(context);
// 按Home按键
MonitorService.invokeMp3(context, false);
} else if (reason.equals("recentapps")) {
MonitorService.invokeMp3(context, true);
}
}
}
}
}