2016-03-28 113 views

回答

1

您可以在通知接收者類中使用服務和廣播接收器。當您收到通知時,請發送廣播。將數據添加到您的列表中並將其設置爲適配器。

+0

你可以給我的代碼.. –

+0

@PrachiKarapurkar [如何使用廣播傳遞數據](http://stackoverflow.com/questions/10032480/how-to-pass-data-to-broadcastreceiver) – Aks4125

+1

OnReceiver你可以添加並設置您的適配器。 –

0

你可以做這樣的事情......

// [START receive_message] 
@Override 
public void onMessageReceived(String from, Bundle data) { 
    String message = data.getString("message"); 
    String code = data.getString("code"); 

    Log.e(TAG, "From: " + from); 
    Log.e(TAG, "Message: " + message); 


    if (from.startsWith("/topics/")) { 
     // message received from some topic. 
    } else { 
     // normal downstream message. 
    } 


    Noty_bean noty = new Noty_bean(); 

    noty.setTitle("Title"); 
    noty.setMessage(message); 
    noty.setTimestamp(System.currentTimeMillis()); 
    noty.setState(0); 
    noty.setNoty_id("default id"); 

    Intent intent = new Intent(this,Your_refresh_service.class); 
    Bundle bundle = new Bundle(); 
    bundle.putSerializable("noty",noty); 
    intent.putExtra("bundle",bundle); 
    startService(intent); 

// sendNotification(message); 
    // [END_EXCLUDE] 
} 
+0

thanq,但它不工作.. –

+0

通知數據m從本地數據庫m保存在數據庫n m檢索並設置列表如何我可以用新數據更新回收視圖 –

+0

@PrachiKarapurkar您需要從您的服務更新活動....檢查它.. http://stackoverflow.com/a/4739898/3790052 –