version:1.1
fix: update:增加推送
This commit is contained in:
60
app/src/main/java/com/uiui/zyos/push/PushManager.java
Normal file
60
app/src/main/java/com/uiui/zyos/push/PushManager.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package com.uiui.zyos.push;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.uiui.zyos.disklrucache.CacheHelper;
|
||||
import com.uiui.zyos.utils.ToastUtil;
|
||||
|
||||
public class PushManager {
|
||||
private static final String TAG = PushManager.class.getSimpleName();
|
||||
|
||||
public static final String SET_ALARMCLOCK = "zuoyeos.action.change.alarmclaock";
|
||||
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static PushManager sInstance;
|
||||
private Context mContext;
|
||||
private ContentResolver mResolver;
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
private PushManager(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
this.mResolver = context.getContentResolver();
|
||||
this.mCacheHelper = new CacheHelper(context);
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new PushManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static PushManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init PushManager first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
//闹钟
|
||||
private static final String JIGUANG_ALARM_CLOCK = "57";
|
||||
|
||||
public void setPushContent(String title, String extras) {
|
||||
switch (title) {
|
||||
case JIGUANG_ALARM_CLOCK:
|
||||
ToastUtil.betaShow("收到推送消息: 设置闹钟");
|
||||
Intent intent = new Intent(SET_ALARMCLOCK);
|
||||
mContext.sendBroadcast(intent);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user