這是我的MyReceiver.java類,在這裏我寫了一個代碼來顯示單個通知。如何在這裏創建多個通知。如何創建多個通知?
public class MyReceiver extends BroadcastReceiver{
String Reqpopending;
int MID=0;
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(context, SplashScreen.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mNotifyBuilder = new NotificationCompat.Builder(
context).setSmallIcon(R.drawable.dashboard)
.setContentTitle("Dash Board Counts")
.setContentText("P.O Counts-532,198,654,255,901 ZeroInward-303 PartialInward-777").setSound(alarmSound)
.setAutoCancel(true).setWhen(when)
.setContentIntent(pendingIntent)
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
notificationManager.notify(MID, mNotifyBuilder.build());
MID++;
}
這是什麼問題?當onReceive被調用時,是否每個通知都會替換或想要發出多個通知? –
我想在調用這個類時顯示多個通知 – prabhu
我想你每次生成新的通知時都需要爲'MID'設置不同的值,以便有多個通知 – DeltaCap