0

I am searching for the latest code for creating notification because the code I have doesn't work and it says that the code is deprecated.

My code is literally similar to an answer to this question, except that mine looks like this...

And on my manifest it turns red, idk why;

enter image description here

However I also have this code(and it works) but I can't figure a way on how to make it repeat daily on a specified time;

    Intent i = new Intent(this,MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), i, 0);

    Bitmap bitmapI = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher_round);

    Notification notification = new Notification.Builder(this)
            .setContentTitle("Sample title")
            .setContentText("Sample content")
            .setSmallIcon(R.mipmap.ic_launcher_round)
            .setLargeIcon(bitmapI)
            .setContentIntent(pendingIntent)
            .build();

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notification.flags |=  Notification.FLAG_AUTO_CANCEL;
    notificationManager.notify(0, notification);`

If you guys wanted to see my actual code just say and i will edit my question.

0 Answers0