Create custom notifications for android app
In my app i want to diaplay the notifications. A background service will get the notifications if there are any and then a small tab like in facebook notifications for iphone will come up from bottom and display the notifications.
On click of the no开发者_如何学JAVAtifications tab user will be navigated to the notifications scree.
I am not able to think which feature to use here and how? Please help.
Also please note that i donot want to display this in notification in notification bar but a custom notification within my app only.
This feature is called Notification.
Then you can use it like this:
mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(this, YourActivity.class);
Notification notification = new Notification(R.drawable.icon, "Notify", System.currentTimeMillis());
notification.setLatestEventInfo(YourClass.this, "App Name","Description of the notification", PendingIntent.getActivity(this.getBaseContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
mManager.notify(APP_ID, notification);
Ok in your edit I see that you want to have a notifaction service only for your app. But then I don't understand this sentence:
On click of the notifications tab user will be navigated to the notifications screen.
What should happen if the user clicks on your notification? Should really the native notification screen be displayed? Or should it switch back to the application? But you're already in this application since you're using a custom notification.
However I would just use a UI element at the bottom, that is always there but not visible. As soon as you have to create a new notification I would set the text of this UI element accordingly and make it visible. When the user clicks on the UI element, it again gets invisible. Using this approach you don't need a background service and all the other stuff.
精彩评论