Please see the following code
wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if (wifi.isWifiEnabled() == false)
{
Toast.makeText(getApplicationContext(), "wifi is disabled..making it enabled", Toast.LENGTH_LONG).show();
wifi.setWifiEnabled(true);
}
Though I have added the permission in manifest file as
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.wifi"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<user-permission android:name="android.permission.ACCESS_WIFI_STATE" />
but still it is giving following error
11-23 15:18:24.399: E/AndroidRuntime(6800): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.wifi/com.test.wifi.WifiDemoActivity}: java.lang.SecurityException: WifiService: Neither user 10082 nor current process has android.permission.ACCESS_WIFI_STATE.
Please help why this is happening