0

[Facebook notification list]I need to add Facebook app like notifications List into my app, My app will generate posts and those are submitted to the servers, any comments added onto any post will into the applications . So i need to create one notification list like facebook with relative time elapsed , which shows list of notifications like

 "Ragav  commented on post no-24, 6 mins ago" .

Can any one help me to how could i make notification list like Facebook, what things need to be there to create notification list ? Thank You ! See the image , I was asking about this .

enter image description here

  • you have to use push notification for that!!! Reference--> http://androidexample.com/Android_Push_Notifications_using_Google_Cloud_Messaging_GCM/index.php?view=article_discription&aid=119&aaid=139 http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/ – Chaudhary Amar Jul 03 '15 at 06:01
  • Push notifications are not required in my application. I need to show list of notifications to the user and need to maintain read and unread count of notifications . – Amit Kumar Kannaujiya Jul 03 '15 at 06:11
  • use GCM google cloud messaging as - https://developers.google.com/cloud-messaging/ – Akshay Paliwal Jul 03 '15 at 06:13
  • if you want to use your server for this then you have to use push notification and GCM!! – Chaudhary Amar Jul 03 '15 at 06:18

3 Answers3

0

GCM (Google cloud Messaging).you can generate push notification wherever you need.

http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

private static void generateNotification(Context context, String message) {
    // int notifyID = 1;
    int smallIcon = R.drawable.toreachmelight_blue;
    int requestID = (int) System.currentTimeMillis();
    long when = System.currentTimeMillis();
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Intent notificationIntent = new Intent(context,
            AutoReceivenotifiation.class);
    Date d = new Date();
    int uniqueID = d.getSeconds();
    notificationIntent.putExtra("shareloc_name", group_name);
    // context.startActivity(notificationIntent);
    /*
     * notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP |
     * Intent.FLAG_ACTIVITY_NEW_TASK);
     */
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingNotificationIntent = PendingIntent.getActivity(
            context, requestID, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
            context);
    mBuilder.setSmallIcon(smallIcon)
            .setAutoCancel(true)
            .setTicker(type)
            .setContentTitle("ToReachMe")
            .setContentText(Html.fromHtml("<u>" + type + "<u>"))
            .setWhen(when)
            .setContentIntent(pendingNotificationIntent)
            .setDefaults(
                    Notification.DEFAULT_LIGHTS
                            | Notification.DEFAULT_VIBRATE)
            .setSound(
                    Uri.parse("android.resource://"
                            + context.getPackageName() + "/" + R.raw.beep));
    notificationManager.notify((int) uniqueID, mBuilder.build());
}
Pang
  • 9,564
  • 146
  • 81
  • 122
preethi
  • 222
  • 2
  • 12
0

use webview and in webview use SSE html5 and get the data from webview.

HTML5 SSE

How to get webview content

Community
  • 1
  • 1
joshua pogi 28
  • 521
  • 1
  • 6
  • 15
0

This is a library you can use to get relative time text, to get 6 min ago, just now etc

https://github.com/curioustechizen/android-ago

Fahmi Sidik
  • 189
  • 5
  • 13