Hello,
I want to show a notification evey x days(the user will define this
value). For that i created a class that extends a BroadCastReceiver
and the main class the launch this receiver:
public class OnAlarmReceiver extends BroadcastReceiver{
        @Override
         public void onReceive(Context context, Intent intent) {


                String ns = Context.NOTIFICATION_SERVICE;
                NotificationManager mNotificationManager = (NotificationManager)
context.getSystemService(ns);

                int icon = R.drawable.icon;
                CharSequence tickerText = "Votre vidange approche";
                long when = System.currentTimeMillis();

                Notification notification = new Notification(icon, tickerText,
when);


                CharSequence contentTitle = "Notification";
                CharSequence contentText = "Vérifier votre kilométrage";
                Intent notificationIntent = new Intent(context, Acceuil.class);
                PendingIntent contentIntent = 
PendingIntent.getActivity(context, 0,
notificationIntent, 0);

                notification.setLatestEventInfo(context, contentTitle, 
contentText,
contentIntent);

                final int HELLO_ID = 1;

                mNotificationManager.notify(HELLO_ID, notification);
         }

        }

And the function in the other main class to launch it:
    public void repeating() {
        AlarmManager
mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        Intent i=new Intent(context, OnAlarmReceiver.class);
        PendingIntent pi=PendingIntent.getBroadcast(context, 0, i, 0);
        mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime()+ 10 * 1000, 1800000, pi);

    }

I never had a notification in my phone. Why?
Thank you very much for your help.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to