0

I have added one broadcast receiver in my androidmanifest for "PACKAGE_ADDED" action.

This broadcast is received for all packages installation.

But I want to get intimated only for selected packages. Those packages are developed by me so I can put some common attributes like same sharedUserId or package name prefix.

My receiver should be invoked only when those packages are installed.

Is there any way to do that ?

David Wasser
  • 93,459
  • 16
  • 209
  • 274

2 Answers2

0

Inside of the onReceive() use intent.getIntExtra(Intent.EXTRA_UID); to get the UID of the added package. You can then compare this to a list of your own packages using the answer here as a starting point

Community
  • 1
  • 1
Shane
  • 150
  • 6
  • yes, that can be done; but my receiver will be launched anyway. I do not want to invoke my receiver for other packages; this is the requirement. – Rupayan Dutta May 14 '14 at 08:18
0

This isn't possible. You cannot specify the package name in the <intent-filter>, so if you are interested in getting these broadcast Intents, you will need to get them all and just ignore the ones you don't care about.

David Wasser
  • 93,459
  • 16
  • 209
  • 274