我有一个通知服务,但似乎通知每次都会在一分钟左右被解雇。请帮帮我。以下是我的服务类的代码。另请注意,如果有多个通知,很少有人会错过。我的意思是没有警报或通知。
public class ReminderService extends WakeReminderIntentService {
AlertDialog alertDialog;
int currentVolume;
public ReminderService() {
super("ReminderService");
}
@Override
void doReminderWork(Intent intent) {
Log.d("ReminderService", "alarm");
Long rowId = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID);
NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Intent i = new Intent(this, ReminderShowActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra(RemindersDbAdapter.KEY_ROWID, rowId);
PendingIntent pi = PendingIntent.getActivity(this, 0,i, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
Notification note = builder.setContentIntent(pi)
.setSmallIcon(android.R.drawable.stat_sys_warning).setTicker("New Alert Reminder")
.setAutoCancel(true).setContentTitle("Alert from Call-You-Back")
.setContentText("Click Me Respond !!").build();
builder.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
note.sound = Uri.parse("android.resource://com.xxxxxxxxxxx.com/raw/sound");
note.vibrate=new long[] { 1000, 1000, 1000, 1000, 1000 };
note.flags |= Notification.FLAG_AUTO_CANCEL;
int id = (int) ((long) rowId);
mgr.notify(id, note);
}