Android: GCM推送后如何查看另一个片段?

Android: How can I get a view of another fragment after GCM push?

我正在尝试在收到 GCM 推送通知后更新我的列表视图。 我从数据库(而不是从推送本身)更新 listView,但是当我尝试获取视图时,它给了我 null 和崩溃(尝试了“GetView,getActivity ... findViewById”)。

还有其他建议吗?

这是我的代码的小示例: [GCM Class]:

public void onMessageReceived(String from, Bundle data) {
        DataBaseHelper myDbHelper = new DataBaseHelper(this.getApplicationContext());
        if(myDbHelper.checkDataBase()) {
            DbServer gsh = new DbServer(getApplicationContext(),"getSQLiteHistory");
            //This might be an issue:
            gsh.setListener(new AlertsList());
            gsh.mContext=getApplicationContext();
            gsh.execute();
        }

[DataBaseHelper Class]

...
   //publish the list via listener
        mListener.finishRefresh(rowItems);

听众:

public interface OnTaskCompleted{
    void finishRefresh(List<RowItem> rowItems);
}

[AlertList Class(包含 "finishRefresh" 函数)]

listView = (ListView) getView().findViewById(R.id.list); //This is null

任何人都可以指出在 GCM 之后我可以从哪里获取视图来更新它?

提前致谢!

伊兰.

getView() 自 GCM 启动此进程(服务)后为空。 我做了什么,我将 "finishRefresh" 函数分离为一个新函数,一旦它来自 CGM class,然后从 inflater 获得视图,然后我才有正确的视图(未为空)