2016-03-28 103 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 –