android: notify the user from service
I have to display notification to the user from service always running in background.
I read that we have to use status bar notification to achieve this. But in the status bar icon is very small and user mi开发者_JAVA百科ght miss it. I want to notify user similar to "new call notification" or "new message notification"
Please help me how can I construct such notifications.
Thanks in advance.
'new message notification' uses the same notification api you are talking about it just displays the message in the status bar. A new call is an Activity
. You can start an activity from you service like this
startActivity(this, MyActivity.class);
When you create a notification, use
final Notification notification = new Notification(
icon,
"New Message Notification", // <-------
System.currentTimeMillis());
Consider using the buzzbox sdk for running background tasks and creating notifications. Have a look at http://hub.buzzbox.com - open source apps are available as examples.
精彩评论