Q: updating gridview in BroadcastReceiver I have a fragment with a gridview which contains list of downloadable items,i need to update gridview downloaded items but i have some difficulties to get gridview in BroadcastReceiver.  bellow is my BroadcastReceiver code:
BroadcastReceiver griddownloadReceiver = new BroadcastReceiver() {

      @Override
      public void onReceive(Context context, Intent intent) {
       //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
       //check if the broadcast message is for our Enqueued download
       long referenceId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);

       GridView gv1=(GridView)getView().findViewById(R.id.grid_view);
       adapter = (GridAdapter) gv1.getAdapter();
       //final GridAdapter adapter = (GridAdapter) ((GridView) getView()).getAdapter();
       adapter.setDownloadFinished(referenceId);

       // Ask the adapter to refresh the ListView
       adapter.notifyDataSetChanged();

      }
};//end of broadcast reciever

what should i put instead of these 2 lines f code?
 GridView gv1=(GridView)getView().findViewById(R.id.grid_view);
 adapter = (GridAdapter) gv1.getAdapter();


A: 
what should i put instead of these 2 lines f code?

In fragment's onCreateView() save reference to adapter in private field, then access it in your griddownloadReceiver that should be placed in that fragment.
Don't forget about registering it in onResume and unregister in onPause.
Then ensure that method setDownloadFinished(referenceId) works properly.
