나는 경보의 명부가있다, 나는 첫번째를두고 경보를 울릴 때 다음을 둔다. 이것은 작동한다. 그러나 응용 프로그램이 백그라운드에서 충분한 시간 동안 작동하지 않으면 알람이 작동하지 않습니다.배경에있는 AlarmManager
<receiver android:name=".Alertas_Broadcast" >
<intent-filter>
<action android:name="com.pack.pack.Alertas" />
<category android:name="com.pack.pack" />
</intent-filter>
</receiver>
그리고 방송과 새로운 알람 넣어 기능 :
public class Alertas_Broadcast extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
String mensaje = "";
if (extras != null)
mensaje = extras.getString("mensaje");
if (!mensaje.equals("")){
Utilidades.generateNotification(context, mensaje, Main.class, null);
// I put the next alarm calling setNextAlarm with the new parameters
}
}
}
public void setNextAlarm (long milisegundos, String mensaje){
Bundle extras = new Bundle();
extras.putString("mensaje", mensaje);
Intent i = new Intent("com.pack.pack.Alertas");
i.putExtras(extras);
PendingIntent pintent = PendingIntent.getBroadcast(InfoApp.miContexto, (int) milisegundos, i, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarm = (AlarmManager)InfoApp.miContexto.getSystemService(Context.ALARM_SERVICE);
if (milisegundos != 0){
alarm.setRepeating(AlarmManager.RTC_WAKEUP, milisegundos, 99999999, pintent);
}
else{
alarm.cancel(pintent);
}
}
문제가를
나는 매니페스트에 넣어? 문제는 수신자의 행동이라고 생각하지만 어떻게 해결해야할지 모르겠다. 많은 리소스를 소비하기 때문에 항상 듣는 것이 좋지 않습니다.
죄송합니다. 내 영어로 죄송합니다. 감사합니다.
데이터베이스의 다음 날짜를 검색하고 새 매개 변수로 setNextAlarm을 호출합니다. 매니페스트에 WAKE_LOCK 권한이 있지만 서비스가 없습니다. – user1852854