android - Pass data to BroadcastReceiver from Activity using DownloadManager -


I am trying to pass a broadcast receiver to an object that will do something when the download completes. How can I use intent objects in the Broadcast Reserves Recipe? I have this activity in my:

  DownloadManager manager = (DownloadManager) getSystemService (context.DOWNLOAD_SERVICE); Long id = manager. Nq (request);   

And I have it in my broadcast receiver, when the download is complete, stuff happens:

  DownloadManager mgr = (DownloadManager) context.getSystemService (Context.DOWNLOAD_SERVICE);   

All this works well, my broadcast receiver does the work that I need when the download is completed. But now I want to pass the object to the Broadcast receiver with my object. Generally, I will make just one intent and add the object to the intent. But, I have not made any intention in my code because the broadcast receiver answers the download using the reference. DOWNLOAD_SERVICE

In my broadcast receiver, I want to get the object to get data from the object (on) method here:

  override public zero at @receive (references Context, intent to intent) {intent.getParcelableExtra ("Object"); }   

How do I obtain data from my activity in this effect? How do I use it? I tried to use getIntent (). PutExtra ("object", object) but it seems that there is a different intention than the Broadcast receiver used in the receipt method because I receive a nullPointerException

Edit: Here is my relevant code in AndroidManifest.xml

  & lt; Receiver Android: name = "com.android.devon.appfrenzy.DownloadReceiver" android: exported = "true" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.intent.action.DOWNLOAD_COMPLETE" /> & Lt; / Intent-Filter & gt; & Lt; / Receiver & gt;    

Before the download is executed, save the price in the shared value < Pre> editor.putInt (main activity.CERIS_LAST_DW_ID_KATALOG, m_intIdKatalog); editor.commit ();

Then get value from Shared Choices on Reader

  Override public zero at @Receive (Reference ARG0, Intent ARG1) {// TODO Automatically Generated Methods Stub Shared Presentations Emirs; MCeris = arg0.getSharedPreferences (main activity. CERIS_PREFERENCES, context. MODE_PRIVATE); Int m_intIdKatalog = mCeris.getInt (main activity.CERIS_LAST_DW_ID_KATALOG, 0); }    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -