2

For example, when we register BroadcastRecievier for WifiManager.WIFI_STATE_CHANGED_ACTION we add needed permission value in the app's manifest :

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

Does it mean that given permission is broadcasted in a manner similar to : sendBroadcast(intent, "android.permission.ACCESS_WIFI_STATE") ?

I tried to register for this event specifing exact permsission :

registerReceiver(receiver, filter, "android.permission.ACCESS_WIFI_STATE", null)

, however did not recieve that even anymore.

Am I missing something ?

2
  • I am not aware that you need that permission to listen for that broadcast. It's certainly not documented as being required. Jul 24, 2013 at 13:36
  • 1
    @CommonsWare The thing is that not only it is not required, but, in fact, if permission is set when registerReceiver the intent is no longer delivered - I have verified that, trying different permission values.
    – kiruwka
    Jul 24, 2013 at 17:24

1 Answer 1

1

You are partially correct. The sendBroadcast method is called as sendBroadcast(intent, "android.permission.ACCESS_WIFI_STATE") by the system framework. But the point is, the second argument is only for the android system to cross check whether the receiving components/applications has this permission.
However registerReceiver(receiver, filter, "android.permission.ACCESS_WIFI_STATE", null) is different case altogether. The permission string in this method means, this particular broadcast can be sent only by the apps that uses this permission in the manifest. it is similar to the android:permission attribute in the manifest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.