私のプロジェクトでは、HTTP に接続してオンラインかどうかを確認するサービスがあります。すべてがうまく機能し、接続します。
問題は、デバイスがスリープ状態になるときです。
画面がオフの場合でもプロセスが実行されるように、RTC_WAKEUP を使用して AlarmManager を使用してチェック イベントをトリガーします...
問題は、これが実際には起こっていないことです。アプリの裏で何が起こっているかを確認するために、Logging Method を作成しました。
私はすべてのステップを記録し、いつ、どのように物事が起こっているかを確認するために、それが起こった時間を書き留めています.
デバイスをスリープ状態に設定し、数分後に戻ってくると、デバイスがスリープ状態ではなく、デバイスを起動したときにのみアラームがトリガーされていることがわかります。
アラームを作成するコードは次のとおりです。
public static void AddAlarm(Context pContext, Server pServer)
{
    // Create pending with intent and server object with a helper that creates  my pending intent.
    PendingIntent pending = IntentGenerator.GetPendingIntentForAlarm(pContext,pServer.ServerId);
    // Get alarm manager
    AlarmManager alarm = (AlarmManager)pContext.getSystemService("alarm");
    // Get current time to start now.
    long startNow = new Date().getTime()-10;
    // Set repeating alarm with current time to start, and interval.
    alarm.setRepeating(AlarmManager.RTC_WAKEUP ,startNow, pServer.GetIntervalInMilliseconds(), pending);
}
そして、保留中の意図をどのように作成するのか疑問に思っている場合:
public static Intent GetIntentForService(Context pContext, int pServerId)
{
    // Comienzo la alarma.
    Intent retVal = new Intent(pContext, ServerStatusCheckService.class);
    retVal.putExtra("SERVER_ID", pServerId);
    return retVal; 
}