user2627112
user2627112

Reputation: 31

sendBroadcast ConnectivityManager.CONNECTIVITY_ACTION

Intent intent = new Intent().setAction(ConnectivityManager.CONNECTIVITY_ACTION);
sendBroadcast(intent);

Exception:

java.lang.RuntimeException: Unable to start activity ComponentInfo{Activity_Index}: 
java.lang.SecurityException: Permission Denial: not allowed to send broadcast 
android.net.conn.CONNECTIVITY_CHANGE from pid=19360, uid=10052

Manifest permissions:

<!-- Connectivity Manager -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<!-- Connectivity Manager -->


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

Upvotes: 3

Views: 3902

Answers (1)

jtt
jtt

Reputation: 13541

You are not allowed to send this broadcast. If applications could send this broadcast then this could cause problems on the device. This is a protected system broadcast.

Please approach your problem in a different way.

Refer: http://developer.android.com/reference/android/net/ConnectivityManager.html

Notice how there are only a few methods that use that action. This implies you cannot send this broadcast.

Upvotes: 4

Related Questions