I found that I am using a deprecated method for noficitations (notification.setLatestEventInfo())
It says to use Notification.Builder.
- How do I use it?
When I try to create a new instance, it tells me:
Notification.Builder cannot be resolved to a type
It works even in API 8 you can use this code:
Or I suggest to follow an excellent tutorial about this
Notification.Builder API 11 or NotificationCompat.Builder API 1
This is a usage example.
UPDATE android-N (march-2016)
Please visit Notifications Updates link for more details.
sample code.
in addition to the selected answer here is some sample code for the
NotificationCompat.Builder
class from Source Tricks :This is in API 11, so if you are developing for anything earlier than 3.0 you should continue to use the old API.
Update: the NotificationCompat.Builder class has been added to the Support Package so we can use this to support API level v4 and up:
http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html