2017-01-06 8 views
0

私のアプリの毎日の通知を実装したいと思います。私の男を助けてくださいCannot resolve symbol "MID"通知システムandroid - 'MID'を解決できません

を:

public class AlarmReceiver extends BroadcastReceiver{ 

    @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, ActivitySplashScreen.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.diamond) 
       .setContentTitle("Alarm Fired") 
       .setContentText("Events To be PErformed").setSound(alarmSound) 
       .setAutoCancel(true).setWhen(when) 
       .setContentIntent(pendingIntent) 
       .setVibrate(new long[]{1000, 1000, 1000, 1000, 1000}); 
     notificationManager.notify(MID, mNotifyBuilder.build()); 
     MID++; 

    } 

} 

私は取得しています:私はAlarmReceiverの問題を持っています!私は初めてこのエラーが発生しました

答えて

0

MIDは私が推測するようにユニークな整数になります。 あなたは(int) ((new Date().getTime()/1000L) % Integer.MAX_VALUE)

がthiswill

notificationManager.notify((int) ((new Date().getTime()/1000L) % Integer.MAX_VALUE), mNotifyBuilder.build()); 
+0

があなたの問題が解決されない各通知に固有のIDを生成してみてください –

関連する問題