-1
我從JSON數據和SQLite中保存eith一個for
,我想在每一個數據在數據庫保存做一個通知,這個數據安卓:在通知數據的顯示列表
我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);
我想表現出一個通知所有的,不喜歡這個
目前尚不清楚誰就會得到通知,但您可以通過添加廣播服務和執行reciver使用LocalBroadcastManager –