This question is an exact duplicate of:
Hi im trying to get my notification to display a random message from a list.
mManager = (NotificationManager) this.getApplicationContext().getSystemService(this.getApplicationContext().NOTIFICATION_SERVICE);
Intent intent1 = new Intent(this.getApplicationContext(),MainActivity.class);
Notification notification = new Notification(R.mipmap.ic_launcher,"Hey!!!", System.currentTimeMillis());
intent1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP| Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingNotificationIntent = PendingIntent.getActivity( this.getApplicationContext(),0, intent1,PendingIntent.FLAG_UPDATE_CURRENT);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(this.getApplicationContext(), "My favorite fruit is the", "", pendingNotificationIntent);
mManager.notify(0, notification);
Where it says "my favorite fruit is", "" i want those to be random strings. When i tried to make the an array and choose a random string from in the array it force closed.
Aucun commentaire:
Enregistrer un commentaire