vladimir
vladimir

Reputation: 733

Turning on/off WiFi

I have some question... I need to know is Wifi on my device enabled or disabled, so i check it with this code:

//check for internet connection
    WifiManager wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
    boolean wifiEnabled = wifiManager.isWifiEnabled();
    if (!wifiEnabled)
    {
        wifiManager.setWifiEnabled(true);
    }
    else
    {
        Toast.makeText(getApplicationContext(), "WiFi is disabled!", Toast.LENGTH_LONG).show();
    }

and i need to add some permissions into manifest, and here i got an error, because <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"/> is only for system programms....

so i ask you for help, how i can turn my app into system, or maybe i have been added some extra permission?

all permissions for Wifi i had added:

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

Upvotes: 2

Views: 924

Answers (1)

Leo Landau
Leo Landau

Reputation: 1795

As implied by your error message, I suggest to delete the UPDATE_DEVICE_STATS permission.

Upvotes: 1

Related Questions