需要在我的应用中添加Facebook应用程序,如通知

时间:2015-07-03 05:59:49

标签: android notifications android-notifications

[Facebook通知列表]我需要将Facebook应用程序像通知列表一样添加到我的应用程序中,     我的应用会生成帖子,并将这些帖子提交给服务器,     添加到任何帖子的任何评论都将进​​入应用程序。     所以我需要创建一个像facebook一样的通知列表      时间已过,显示通知列表,如

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

任何人都可以帮助我如何制作像Facebook这样的通知列表,需要在那里创建通知列表? 谢谢 !  看到图片,我问的是这个。

enter image description here

3 个答案:

答案 0 :(得分:0)

GCM(Google云消息传递)。您可以随时随地生成推送通知。

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());
}

答案 1 :(得分:0)

使用webview并在webview中使用SSE html5并从webview获取数据。

HTML5 SSE

How to get webview content

答案 2 :(得分:0)

这是一个可以用来获取相对时间文本的库,可以在6分钟前获得,刚才等等

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

相关问题