-1

I get data from json and save in sqlite eith a for ,I want when each data save in db make a notification with this data

my for

for(int i=0;i<jnews.length();i++){
    JSONObject c = jnews.getJSONObject(i);
    String id = c.getString(TAG_ID);
    String title = c.getString(TAG_ONVAN);
    String text = c.getString(TAG_MATN);
    String data = c.getString(TAG_TARIKH);
    String nid = c.getString(TAG_CNID);

    HashMap<String,String> nnews = new HashMap<String,String>();

    nnews.put(TAG_ID,id);
    nnews.put(TAG_ONVAN,title);
    nnews.put(TAG_MATN,text);
    nnews.put(TAG_TARIKH,data);
    nnews.put(TAG_CNID,nid);

    newsList.add(nnews);

    db.setNewNews(id, title, text, data, nid);
}

I use this code in for,but not good

String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

int icon = R.drawable.ic_launcher;        
CharSequence tickerText = "ثبت اختراع"; // ticker-text
long when = System.currentTimeMillis();         
Context context = getApplicationContext();     
CharSequence contentTitle = title;  
CharSequence contentText = title + data;
Intent notificationIntent = new Intent(this, NewsActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

mNotificationManager.notify(i, notification);

i want show all in one notification,Not like this

enter image description here

sadegh
  • 1,720
  • 1
  • 16
  • 30
  • It's not clear who will get notify but you can use LocalBroadcastManager by adding a Broadcast service and implementing a reciver – Umesh Aawte Jul 11 '15 at 05:55

1 Answers1

1

check the below link for information about appending text with a notification builder.

Notification Builder

Community
  • 1
  • 1
darwin
  • 1,524
  • 1
  • 22
  • 32