android6.0以上开启热点失败

    最近在做手机移动端文件传输app,该项目需要一端开启热点,另一端连接该热点,从而两个段之间建立局域网,进而通过socket通信实现文件传输功能,随着测试的深入,发现,如果设置targetSdkversion >= 23的时候热点创建失败。百度了一下,全是权限的问题,通过打印我的log,也提示是权限问题,log如下:

08-18 13:12:01.907 21072-21794/? W/System.err: java.lang.reflect.InvocationTargetException
08-18 13:12:01.907 21072-21794/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
08-18 13:12:01.907 21072-21794/? W/System.err:     at com.tpvtransfer.manager.WifiAPManager.setWifiApEnable(WifiAPManager.java:191)
08-18 13:12:01.907 21072-21794/? W/System.err:     at com.tpvtransfer.sdk.SDKManager.createAp(SDKManager.java:66)
08-18 13:12:01.907 21072-21794/? W/System.err:     at com.tpvtransfer.NewDeviceActivity.createAp(NewDeviceActivity.java:482)
08-18 13:12:01.908 21072-21794/? W/System.err:     at com.tpvtransfer.NewDeviceActivity.access$23(NewDeviceActivity.java:480)
08-18 13:12:01.908 21072-21794/? W/System.err:     at com.tpvtransfer.NewDeviceActivity$WorkingHandler.dispatchMessage(NewDeviceActivity.java:470)
08-18 13:12:01.908 21072-21794/? W/System.err:     at android.os.Looper.loop(Looper.java:203)
08-18 13:12:01.908 21072-21794/? W/System.err:     at android.os.HandlerThread.run(HandlerThread.java:61)
08-18 13:12:01.908 21072-21794/? W/System.err: Caused by: java.lang.SecurityException: com.tpv.transfer was not granted  this permission: android.permission.WRITE_SETTINGS.
08-18 13:12:01.908 21072-21794/? W/System.err:     at android.os.Parcel.readException(Parcel.java:1683)
08-18 13:12:01.908 21072-21794/? W/System.err:     at android.os.Parcel.readException(Parcel.java:1636)
08-18 13:12:01.908 21072-21794/? W/System.err:     at android.net.wifi.IWifiManager$Stub$Proxy.setWifiApEnabled(IWifiManager.java:1751)
08-18 13:12:01.909 21072-21794/? W/System.err:     at android.net.wifi.WifiManager.setWifiApEnabled(WifiManager.java:1667)


好吧,但是我命名在menifest已经注册了write_settings权限了啊?


不然怎么说自古网络出人才,http://blog.csdn.net/chengkaizone/article/details/53765934,然后选择开启,编译安装,正常开启热点,marks一下。

你可能感兴趣的:(android)