I need to call notification manager after ever 5 min
Main Activity
Calendar cal = Calendar.getInstance(); //for using this you need to
import java.util.Calendar;
// add minutes to the calendar object
//cal.set will set the alarm to trigger exactly at: 21:43, 5 May 2011
//if you want to trigger the alarm after let's say 5 minutes after is
activated you need to put
cal.add(Calendar.MINUTE, 1);
Intent alarmintent = new Intent(getApplicationContext(),
AlarmReciever.class);
alarmintent.putExtra(title,Title of our Notification);
alarmintent.putExtra(note,Description of our Notification);
int HELLO_ID =1;
PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(),
HELLO_ID,
alarmintent,PendingIntent.FLAG_UPDATE_CURRENT| Intent.FILL_IN_DATA);
//VERY IMPORTANT TO SET FLAG_UPDATE_CURRENT... this will send correct
extra's informations to
//AlarmReceiver Class
//am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);
am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+ (10 * 1000),
sender);
Manifest.xml
receiver android:name=.AlarmReciever/receiver
AlarmReciever
package com.mobileconnect; import android.app.Notification; import
android.app.NotificationManager; import android.app.PendingIntent; import
android.content.BroadcastReceiver; import android.content.Context; import
android.content.Intent; import android.content.SharedPreferences; import
android.net.Uri; import android.widget.Toast; public class AlarmReciever
extends BroadcastReceiver { public String username=null; public String
password=null; SharedPreferences mPrefs; String PREFS = MyPrefs; Cryption
crypt=new Cryption(); @Override public void onReceive(Context context,
Intent intent) {
Toast.makeText(context.getApplicationContext(),listAvtivity.NotiCountValue
+Reciver Starts, Toast.LENGTH_LONG).show(); mPrefs
=context.getSharedPreferences(PREFS,0); username =
mPrefs.getString(login, null); password = mPrefs.getString(password,
null); String encryptUsername=crypt.Encrypt(username); String
encryptPassword=crypt.Encrypt(password); String ns =; ns=
Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager =
(NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE); int icon =
R.drawable.icon; CharSequence tickerText = Mobile Connect; long when =
System.currentTimeMillis()+(5 * 1000); Notification notification = new
Notification(icon, tickerText, when); CharSequence contentTitle = Mobile
Connect; CharSequence contentText =listAvtivity.NotiCountValue+ Unread
FranConnect Notifications.; PendingIntent contentIntent =
PendingIntent.getActivity(context, 0, new Intent(Intent.ACTION_VIEW,
Uri.parse(AndroidLogin.ActualServerUrl.toString()
+control/authenticate1?wel= +encryptUsername.trim()+ come=
+encryptPassword.trim()+url=viewAllNotifications )),0);
notification.setLatestEventInfo(context, contentTitle, contentText,
contentIntent); mNotificationManager.notify(0, notification);
notification.defaults |= Notification.DEFAULT_SOUND;
//mNotificationManager.notify(id, notification);
Toast.makeText(context.getApplicationContext(),listAvtivity.NotiCountValue
+ Unread FranConnect Notifications., Toast.LENGTH_LONG).show();
Toast.makeText(context, Repeating Alarm worked.,
Toast.LENGTH_LONG).show(); } }
I need to call AlarmReceiver Call after evry 5 min but it is getting
caaled after every sec pls tell wt am doing wrong
RK
--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en