中製作通知圖標我想在我的應用程序中創建一個通知圖標,該圖標顯示我的應用程序中發生的任何新事件,類似於您在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