3

I have very strange problem.

I am sending broadcast and setting some extras but receiver is not getting them :

Sending :

private void notifyAboutDownload(String reference, Context ctx) {
    Intent i = new Intent(InitialActivity.ACTION_PACKAGE);
    i.setAction(InitialActivity.ACTION_DOWNLOAD_COMPLEATED);
    i.putExtra(InitialActivity.DOWNLOAD_ID, reference);

    ctx.sendBroadcast(i);

}

And receiving :

public void onReceive(Context context, Intent intent) {

        String downloadID =   intent.getExtras().getString(InitialActivity.DOWNLOAD_ID);

        Log.i(TAG, "downloadID :  "+ downloadID);
    }
};

For some reason downloadID is null. Any hints?

thanks

wonglik
  • 1,043
  • 4
  • 18
  • 36
  • http://stackoverflow.com/questions/5216177/sending-extras-to-broadcastreceiver – Tobrun Jan 21 '13 at 22:18
  • @user1281750 unfortunately it did not work – wonglik Jan 21 '13 at 22:36
  • instead of using String downloadID = intent.getExtras().getString(InitialActivity.DOWNLOAD_ID); use this String downloadID =intent.getStringExtra(InitialActivity.DOWNLOAD_ID); – Husam A. Al-ahmadi Jan 21 '13 at 23:22
  • I am doing something similar HERE!!! http://stackoverflow.com/questions/14571564/android-pendingintent-extras-not-received-by-broadcastreceiver/14612215#14612215 – Etienne Lawlor Jan 31 '13 at 07:53

1 Answers1

0

Try setting your intent like this

Intent i = new Intent(getApplicationContext(), MyReceiver.class);
spezzino
  • 664
  • 12
  • 21