Some phones have Wifi Direct apps while having Android OS 2.3.x. But Wifi direct APIs is supported by Android 4.0 or later.
So Can I develop(code) for Wifi direct with Android 2.3, is there any such library or way to do so (for e.g using NDK or else)? Pls give the links or detail! Thanks.
You should see the following links:
WiFi Direct for Android Version 2.3+.
can we have wifi direct api working in 2.3 version.
The answer is NO. You can use built-in wifi direct apps in devices with Android 2.3. Note that in official website, Google only supports Wifi Direct API from Android 4.0.
Strictly speaking no, Wi-Fi Direct is not supported on Gingerbread. Devices running this version of Android will neither be able to act as group owners, nor will they be able to connect to other Wi-Fi Direct devices using Wi-Fi Direct calls.
That said, it is possible for a Gingerbread device to connect to a Wi-Fi Direct device using its standard Wi-Fi interface. On Wi-Fi Direct devices, the WifiP2pManager class defines a createGroup method that makes the device a Group Owner that can not only accept connections from other Wi-Fi Direct devices but also legacy Wi-Fi ones. To achieve this, the device effectively acts as an access point and can be connected to by any Wi-Fi device, including a Gingerbread device.
You would need to devise a mechanism to transfer the SSID and key from the Wi-Fi Direct device to the Gingerbread device. With this, the device could then use Wi-Fi to programatically connect to the Wi-Fi Direct group.
Related
I have a scenario where I want to use wifi to connect to the internet (comfortably via androids settings) and ethernet for accessing local network which is not connected to the internet.
Thus I want to have both ethernet and wifi up simultaneously and use the routing table to send all the local requests to the ethernet and the default to wifi.
I found out android disables wifi when ethernet is enabled...
There has been a fix for an old android version on https://android.googlesource.com/platform/frameworks/base/+/refs/heads/pie-release/services/core/java/com/android/server/ConnectivityService.java
Problem: In Android 9 the file looks different and I cannot find the lines mentioned...
I am using a Khadas Vim3 and their android build.
Can you please help me, which lines need to be changed?
This is the file:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android10-c2f2-release/services/core/java/com/android/server/ConnectivityService.java
Thanks in advance
I'm developing an app that has to make all network requests via mobile data, even when it's connected to wifi. The problem is that Android turns off mobile data when connected to wifi for obvious reasons.
I tried to list all the network interfaces so I could use the right one but, when on wifi, the rmnet0 interface even disappears from the list (on a Samsung S8, at least. I tried with a OnePlus and it didn't disappear, but it's not up).
Is there a way to do that, either with Kotlin or using the NDK (C/C++)?
One thing you could do is disable wifi. That can be done programmatically in Android, provided you have the android.permission.CHANGE_WIFI_STATE permission.
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
wifiManager.setWifiEnabled(isWifiEnabled);
With wifi disabled the phone should switch back to mobile data. As already stated in the comments, that could lead to extra costs for the users and you may want to try to improve the response for wifi instead.
I am working in an application that requires an Android device to connect to a Wi-Fi network. This Wi-Fi network does not have internet access - it is a Wi-Fi network created by a end-device and used only to communicate with it using TCP sockets. I would like to be able to access the cellular data internet connection on the Android device WHILE communicating with this device over Wi-Fi and I wanted to know if this is possible.
Here is what I know so far:
It is possible to get list of all interfaces available on the device and their corresponding IP addresses via the Android NetworkInterface API.
There is an option in the Developer Settings in Android to keep cellular data interface up even when Wi-Fi is connected.
It is possible to provide the local address for the Socket to bind to when creating a Socket()
With these in mind:
When I am connected to the Wi-Fi network with the SIM card in the device and LTE enabled I am able to get wlan0 interface with a "local" IP address in the format 192.168.x.x and rmnet0 interface with a non-local IP address.
However, depending on the device, I am only ever able to access ONE of them at a time.
For example, on a Pixel 2 XL running Oreo 8.1, LTE Enabled, Cellular Data Always On enabled:
I am unable to communicate over Wi-Fi AT ALL. Any Sockets created with the Wi-Fi local address time out.
On a Galaxy Tab S2 SM-T818W running Nougat 7.1, LTE Enabled, Cellular Data Always On enabled:
I am able to communicate over Wi-Fi but not able access the cellular data interface.
The only way I am able to access the wlan0 interface on the Pixel 2 XL is by calling requestNetwork from Android's ConnectivityManager API and requesting Network with TRANSPORT_WIFI capabilities but this defeats the purpose since now all communication and sockets will be bound only to the Wi-Fi network.
I know that when USB tethering is enabled, it is possible to access devices on the Virtual USB "Ethernet Network" interface which shows up as eth0 with either the wlan0 interface or even the rmnet0 interface by specifying local addresses on the Socket connection calls. It just appears to be a problem with Wi-Fi and cellular data.
I wanted to know if this is an inherent and intended Android limitation or is there a way to access both interfaces at the same time that I am missing.
Appreciate your help. Please let me know if it would be better for me to provide specific code snippets, I wasn't sure since it would make this post quite long.
Best,
Is there any other way of Communication between Two Android Devices without Using Sockets Programmed in Java ? Does Java provide some other way to do this stuff ?
Assuming Bluetooth is also not allowed, you can still connect two Android devices together.
You can do this with USB OTG. Some Android devices support this and Android has an official API that supports this.
You need an OTG Connector, a USB cable and one of those Android devices must support OTG.
API reference and examples:
https://developer.android.com/guide/topics/connectivity/usb/index.html
http://android-developers.blogspot.com/2011/05/bright-idea-android-open-accessories.html
Android USB host and hidden devices
Since Android 4.1 Network service discovery (NSD) is available. However, how would one find an android device that exposes an NSD-Service from a computer or from some other device that does not run android. Building an android app as shown in the examples will find the other device just fine, however, one does not always have Android as a platform.
I am running UPnP discovery on my PC and the phone does not show up.
You can find my NSD-Service implemented here on github.
The Discovery app is simple from the android example.
The UPnP example is using Cling and is from their tutorial it finds my router and the windows media player so I assume it works.
It may be that the issue is based on a mismatch of service discovery protocols, I relay am confused as to the differences between NSD, UPnP, Bonjour, Zeroconf and all the other possibilities...
The protocol you are after is http://www.dns-sd.org/ - DNS Service Discovery (DNS-SD)
That seems to be the only protocolType in the current Android framework.