java - wifiSetEnabled(true) occasionally not working -
i'm making first app i'm not expert. btw in app i've create service should enable or disable wi-fi according boolean value i'm passing service through pending intent use start (the service, i'm using alarmmanager this).
now, works fine in cases, wifi won't turn on, , i'm sure service started because complete other works it's supposed do. i first thought permission's fault, can see permission i'm using in manifest below. looking around here in stackoverflow suggested add update_device_stats permission don't think solution because said: works. important: notice can't enable when wifi turned off while, few hours. this snippet service: (tsmanagerhelper class pending intent , values)public int onstartcommand(intent intent, int flags, int startid) { boolean op2; wifimanager wifimanager=(wifimanager)getsystemservice(wifi_service); bundle bundle; if(intent!=null) { bundle = intent.getextras(); op2 = bundle.getboolean(tsmanagerhelper.option2); //wi-fi if(op2 != wifimanager.iswifienabled()){ if(op2) wifimanager.setwifienabled(true); else wifimanager.setwifienabled(false); }
manifest's permissions: <uses-permission android:name="android.permission.change_wifi_state" /> <uses-permission android:name="android.permission.access_wifi_state" /> <uses-permission android:name="android.permission.receive_boot_completed" /> <uses-permission android:name="android.permission.write_settings" /> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permission.access_network_state"/> <uses-permission android:name="android.permission.change_network_state"/>
idea? repeat i'm unexperted, whoever me :)
Comments
Post a Comment