To get the Multiple Notification on android Device

T

use this code to get the multiple notification on Android Device

TO write this code on the set timer

Intent intent = new Intent(SecondActivity.this, MyBroadcastReceiver.class);   intent.putExtra(“ID”, 10);   intent.putExtra(“Val”, “me aahe”);   final int intent_id= (int) System.currentTimeMillis();
PendingIntent p1 = PendingIntent.getBroadcast(getApplicationContext(), intent_id,intent,PendingIntent.FLAG_UPDATE_CURRENT);   AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);   Calendar calendar = Calendar.getInstance();   calendar.setTimeInMillis(System.currentTimeMillis()); //   calendar.add(Calendar.SECOND,i);   alarmManager.set(AlarmManager.RTC_WAKEUP,  System.currentTimeMillis()+ (10 * 1000),p1 );

 

And get the notification onRecive()

Bundle extra=intent.getExtras(); int id=extra.getInt(“ID”); String ab=extra.getString(“Val”); Toast.makeText(context,”To DeActivate coupon  ” +id +ab, Toast.LENGTH_SHORT).show(); NotificationManager mNotificationManager =(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager manger = (NotificationManager)      context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.icon, “”+id, System.currentTimeMillis()); PendingIntent contentIntent = PendingIntent.getActivity(context,id,new Intent(), 0); notification.setLatestEventInfo(context, “HELLO”,””+id, contentIntent); notification.flags = Notification.FLAG_INSISTENT; // notification.defaults |= Notification.DEFAULT_SOUND; notification.flags=Notification.FLAG_AUTO_CANCEL; //notification.number+=1; manger.notify(id, notification);

 

 

About the author

abhijit.kurlekar
By abhijit.kurlekar

Category