中制作通知图标我想在我的应用程序中创建一个通知图标,该图标显示我的应用程序中发生的任何新事件,类似于您在android中找到的新消息或新邮件。你们可以帮助我一个链接或分享你自己的想法,以如何实现这一点..如何在android
-1
A
回答
-2
你可以使用吐司。吐司通知是在窗口表面弹出的消息。 例子:
Toast toast = Toast.makeText(context, text, duration);
toast.show();
你可以看到http://developer.android.com/guide/topics/ui/notifiers/index.html更详细的。
+2
Toast如何处理此问题? – Egor 2012-07-17 07:01:10
0
现在创建Notification
的首选方法是使用Notification.Builder
类。 Here你可以找到这个文档和使用这个类的例子。它有一个setSmallIcon()
方法,这正是你所需要的。希望这可以帮助。
0
发现了一个伟大的教程通知http://www.tutorialspoint.com/android/android_notifications.htm这有更多的细节,但对于一个简单的图标...
您的通知图标复制到文件夹绘制
变量中添加以下到你的活动
private NotificationManager mNotificationManager;
private int notificationID = 100;
添加以下方法
// Start the Notification Icon
protected void displayNotification() {
Log.i("Start", "notification");
/* Invoking the default notification service */
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setSmallIcon(R.drawable.fl_notification);
mBuilder.setContentTitle("Flashlight");
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
/* notificationID allows you to update the notification later on. */
mNotificationManager.notify(notificationID, mBuilder.build());
}
// Stop the Notification Icon
protected void cancelNotification() {
Log.i("Cancel", "notification");
mNotificationManager.cancel(notificationID);
}
相关问题
- 1. 如何在android
- 2. 如何在android
- 3. 如何在android
- 4. 如何在android
- 5. 如何在android
- 6. 如何在android
- 7. 如何在android
- 8. 如何在android
- 9. 如何在Android
- 10. 如何在android
- 11. 如何在android
- 12. 如何在android
- 13. 如何在android
- 14. 如何在android
- 15. 如何在android
- 16. 如何在android
- 17. 如何在android
- 18. 如何在android
- 19. 如何在android
- 20. 如何在android
- 21. 如何在Android
- 22. 如何在android
- 23. 如何在android
- 24. 如何在android
- 25. 如何在android
- 26. 如何在android
- 27. 如何在android
- 28. Android:如何在
- 29. 如何在android
- 30. 如何在android
这是关于如何使图标本身的问题?或者如何在通知中包含图标? – DroidBender 2012-07-17 06:56:06
您可以这样做:通知通知=新通知(图标,文本,时间);其中图标是int icon = R.drawable.ic_launcher;传递你想要保留在通知中的任何图标 – AkashG 2012-07-17 06:58:09
我需要一个图标,我可以传递一个值,该值将显示为没有通知或没有要查看的事件,类似于你在facebook中看到的那样 – Rakshi 2012-07-17 07:03:18