我正在使用PhoneBap的StatusBarNotification插件(Android)来发送通知.现在我想在特定的时间到这个,从我读过的,我必须使用Android的AlarmManager.我已经尝试了一些方法,但似乎无法让它工作.
有关如何做到这一点的任何建议?
编辑:我可以得到通知,以显示我是否将代码放在onReceive()中showNotification().问题似乎是接收器没有收到Alarm-thingy.可能是因为我在IntentFilter中没有正确的操作.
这是我的代码.我从Phonegap的StatusBarNotification插件构建它,在这里找到
public class StatusBarNotification extends Plugin {
// Action to execute
public static final String ACTION="notify";
private Context context;
BroadcastReceiver receiver;
public StatusBarNotification() {
this.receiver = null;
}
public void setContext(PhonegapActivity ctx) {
super.setContext(ctx);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(); //Dunno what to put here
if(receiver == null) {
this.receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("Notification", "inside onReceive");
/*int icon = R.drawable.notification;
long when = System.currentTimeMillis();
NotificationManager manager …Run Code Online (Sandbox Code Playgroud)