Skip to content Skip to sidebar Skip to footer

How To Determine The Sender Of Broadcast Intent

I have an application that is at the same time a broadcast sender and receiver of standard action android.intent.action.SET_WALLPAPER. I want to do some stuff only in a case when a

Solution 1:

No.

If you only want to do something when an action was broadcast by another app (i.e. not yours), I imagine it should be easy to determine that your app didn't send this broadcast, and therefore it was someone else..

Solution 2:

If all you care about is if it was sent by your app or not, what you can do is add an extra to the Intent every time you create one. For example:

broadcastIntent.putExtra('com.android.app.EXTRA_APP_CREATED', true)

Then, when you receive the broadcast, you can check

if (intent.getExtra('com.android.app.EXTRA_APP_CREATED', false) { ... }

To see if you created the intent.

Post a Comment for "How To Determine The Sender Of Broadcast Intent"