How to start a local network connection programmatically via Wi-Fi hotspot on Android?

前端 未结 5 1981
别跟我提以往
别跟我提以往 2020-12-30 06:32

I want to start a local network connection using the built-in Wi-Fi hotspot on Android devices. Is there a way to accomplish it? And how to communicate between two devices?<

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-30 07:20

    Possible answers:

    Before ICS and non rooted devices

    There is no way you can connect to a device over wifi. There is no API to do. Bluetooth is your best option or user interaction.

    Before ICS and rooted devices

    I am not sure if someone hacked the code, but when I tried to do an automatic connection to a wifi spot I noticed:

    • The api is hidden inside the SDK.
    • The method that does the connection checks the thread who ask for it. If it's not the os thread, it throws an exception.

    Using ICS

    With ICS there is a new way to connect devices through wifi called Wi-Fi Direct. Here is a link with some demos.

提交回复
热议问题