Android:show通知中的数据列表
Android:show list of data in notification
我从 json 获取数据并保存在 sqlite 中 for
,我想当每个数据保存在 db 中时用这个数据发出通知
我的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);
}
我在for
中使用了这段代码,但效果不佳
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);
我想在一个通知中显示所有内容,而不是这样
查看下面的内容link,了解有关使用通知生成器附加文本的信息。
Notification Builder
我从 json 获取数据并保存在 sqlite 中 for
,我想当每个数据保存在 db 中时用这个数据发出通知
我的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);
}
我在for
中使用了这段代码,但效果不佳
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);
我想在一个通知中显示所有内容,而不是这样
查看下面的内容link,了解有关使用通知生成器附加文本的信息。
Notification Builder