I\'ve written the code to create an access point for android devices. I\'ve tested on both emulator and real device.But it doesn\'t work. Where did i get wrong?
You need few things to make this code to work.
1) Init wifiManager onCreate()
:
WifiManager wifiManager = (WiFiManager) getSystemService(Context.WIFI_SERVICE);
2) You need to ask for this permissions in you AndroidManifest.xml
:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
3) Your application need to be signed with system certificates.
With your method of exploiting undocumented APIs using reflection, things might not work well in all scenarios. Well, you can try adding these in your manifest file and give a try.
android.permission.ACCESS_WIFI_STATE
android.permission.CHANGE_WIFI_STATE
android.permission.WRITE_APN_SETTINGS
Your WiFiManager
is definately not initialized.
In your onCreate
method add this:
wifiManager = (WiFiManager) getSystemService(Context.WIFI_SERVICE);