In Android M, I used code in How to create wifi tethering Hotspot in Android Marshmallow? to create hotspot, but it is not working.
I get error.:
java.lang.SecurityException: android.tutorial.hotspotcreation was not granted either of these permissions: android.permission.CHANGE_NETWORK_STATE, android.permission.WRITE_SETTINGS.
If I use that hotspot code.
The recommended way, is to use an intent:
startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
Is there a way to create hotspot via code, without user-intervention?