La création d'une Notification à un moment particulier par le biais d'Alarme Manager

Je suis en train de créer une notification à un moment donné. Im la création d'un récepteur de radiodiffusion et en l'appelant par le biais de la AlarmManager. Le problème, c'est que l'émission n'est pas reçu et que je ne reçois pas toutes les notifications.

L'enregistrement du Récepteur de Radiodiffusion dans le Manifeste,

<receiver
        android:name="com.example.android.receivers">
        <intent-filter>
            <action android:name="com.example.android.receivers.AlarmReceiver" />
        </intent-filter>
    </receiver>

C'est le Récepteur de Radiodiffusion,

public class AlarmReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context pContext, Intent pIntent) {

//     if (pIntent.getAction().equalsIgnoreCase("")) {
//         
//     }
        Log.d("Alarm Receiver", "onReceive called");        
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(pContext).setSmallIcon(R.drawable.icon).setContentTitle("Test Notification")
                        .setContentText("Test Notification made by Syed Ahmed Hussain");
        Intent resultIntent = new Intent(pContext, CalendarView.class);

        //The stack builder object will contain an artificial back stack for the
        //started Activity.
        //This ensures that navigating backward from the Activity leads out of
        //your application to the Home screen.
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(pContext);
        //Adds the back stack for the Intent (but not the Intent itself)
        stackBuilder.addParentStack(CalendarView.class);
        //Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        notificationBuilder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager = (NotificationManager) pContext.getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(1, notificationBuilder.build());
    }

}

Code d'Activité Principale, qui crée une Alarme.

/**
     * 
     * @param pDate
     * @param pTime
     */
    private void createNotification(String pDate, String pTime) {
        AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        Intent intent = new Intent(this, AlarmReceiver.class);
        PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
//     alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 60 * 1000, alarmIntent);
        alarmManager.set(AlarmManager.RTC_WAKEUP, Calendar.getInstance().getTimeInMillis(), alarmIntent);
    }

Quelqu'un peut s'il vous plaît signaler et de corriger ce que je fais mal? Merci.

n'ai pas ma réponse vous a aidé?

OriginalL'auteur Ahmed | 2013-11-13