Can I use Wi-Fi Direct and cellular data in an app? - android

I have two+ Android devices. I would like the devices to send instructions to the other devices using Wi-Fi Direct, while at the same time being able to access the internet via their cellular data connection. It seems that using the Wi-Fi Direct interface is being treated as the primary connection, disabling the other connections, just like how Wi-Fi disables the cellular data connection.
How can I programmatically allow both to operate at the same time?
Currently the Wi-Fi Direct receiver is implemented according to Google's Android Developer documents. I was under the assumption that I could use Wi-Fi Direct much like I can use Bluetooth alongside other connections.

Yes it is possible to do that, you can check some articles over here . One of the developers in XDA has developed an application to do that called Super Download Lite and paid version of Super Download - Fast! . You can get details from here and here or you can do some hacking Here is the source code of application which connect to 3G and WiFi to share the connection of the internet (But I am not sure how much it will help you). or try decompiling or revers engineering the Super Download app

Related

Using both Wifi and mobile network at the same time in flutter app

In my flutter app, I need to get information from a device via wifi as a stream. Also I need to keep my google maps online via Mobile internet. How can I use both wifi and mobile network at the same time in my phone. I made a lot of search but I can't find any solution for this.
I don't think it's possible.
The phone would need two network antennas and possibly two network adapters.
You can surely toggle both wifi and mobile data at the same time and they can probably switch frequently to optimize your connection or send requests to different services.
But you can't really use them both at the same time.
(if it's possible) I don't recommend it, since a majority of phones will not support this feature since you need two network antennas.
From the facts as presented, there are a couple of possible solutions, but they aren't perfect and I'm guessing on one as I haven't tested it yet.
One, Google Maps has an offline mode. You can set it up to download maps for offline use. It will show your position on the maps whether you are connected to the internet or not, but you won't get traffic data or accurate travel times. Not great, but it can work.
Two, it is possible for a phone to have a WiFi network and Cellular network active at the same time, but not in the way everyone seemed to think. Since you are wanting the cellular connection open to have access to the internet, I'm assuming this is because the WiFi network you want to access doesn't have the internet. So, reverse the WiFi network. Setup your phone to be a hotspot network, it runs its own WiFi network while maintaining access to the internet through its cellular network. I'm guessing here, but unless phones have some specific security protocol forbidding it I don't know about (which can be the case), your app should be able to contact anything connected to its phone's WiFi while still having access to the internet.
If this doesn't work for some reason, you can try a trick I used when I set up a car office. Get a mobile hotspot device. It's a device you can put a cellular SIMM in and it creates a WiFi hotspot. You can connect to it, along with other devices in the car. All will being using WiFi and the hotspot will provide the internet access.
If what you are connected to can only create a WiFi network for you to access and it can't be configured to connect to one itself, you could technically still be able to do it by network switching. Much harder to do (probably impossible on some devices) and will likely mess with other apps depending on internet access, so a real break glass in case of emergency type of situation there.

Is there any way to transfer data between Android devices without the user having to accept a connection?

I am currently researching task offloading strategies for mobile devices and need to be able to transfer data between devices automatically without the users being on the same WiFi network. As far as I know the user needs to explicitly accept connections both with WiFi Direct(P2P) and Bluetooth.
Is there any way around the explicit connection acceptance? Does other/better options exist?
Anything goes as long as it enables me to share data between devices in an ubiquitous fashion. Preferably without rooting the device.
An alternative is the Google Nearby API. It allows you to discover, connect and send data to nearby devices without any promt and without having to root the device.
Some documentation can be found here: https://developers.google.com/nearby/connections/android/discover-devices
A good code example can be found here: https://github.com/android/connectivity-samples/blob/a7df97eee9b2a553760d338babc6f24e4dc73cf7/NearbyConnectionsRockPaperScissors/app/src/main/java/com/google/location/nearby/apps/rockpaperscissors/MainActivity.java

Android - communicating between two devices

What is the best way for an Android app installed on two devices to communicate with each other? Can the devices connect directly without using text messaging?
You have several options, depending on your requirements and setup:
If your devices are very close to one another (up to about 10 meters), you can communicate using Bluetooth, as Derek suggested.
If your devices are somewhat further away, but within WiFi range of each other (up to about 100 meters), then they can communicate with each other using the Peer-to-Peer WiFi API, documented here (part of the Android Wireless API). This does not require a WiFi router to be present, and the devices will find each other and communicate directly. This does however require Android 4.1 or higher.
The Android Wireless API will also work if your devices are on the same local network (i.e., use the same WiFi router), even if they are not themselves within range of each other.
If none of these options are viable/guaranteed, then I agree with Derek that the easiest way would be to use ServerSocket and Socket to create a server/client interface through the Internet. Here is a sample application doing that. The main problem you might encounter is that if the server is sitting behind a NAT (such as a home internet router), you will have to configure the NAT to forward the incoming packets to your Android server.
You can connect them via bluetooth using BluetoothSockets. Android developer website has pretty good documentation on this.
http://developer.android.com/guide/topics/wireless/bluetooth.html
Or if you'd rather (and have internet on both devices), you can use regular Socket's.
http://developer.android.com/reference/java/net/ServerSocket.html for server side
http://developer.android.com/reference/java/net/Socket.html for client side
If you have a large amount of data to transfer, internet sockets have a greater data capacity and will be faster. The other advantage is that there is no such thing as "out of range". You can connect the two devices wherever internet is available, whereas with bluetooth they have to be within bluetooth range of each other
you can use PubNub. it handles all networking and you should only care about messages.
it has great API to work.
(Thanks to #Ian Jennings : Can we send data from an android device to another android device directly (p2p) without server in the middle?)
Depends on what you are doing. If you have a server, you may be able to send some message to it and have it pulled by the other device (assuming both clients have the app installed). I think this would be the most intuitive way (but it really depends on what you are communicating).
Text messaging and email might work, but you (or the user) needs to know the numbers/emails associated with a device to do that.
you should have a look at WifiDirect
Wi-Fi peer-to-peer (P2P) allows Android 4.0 (API level 14) or later
devices with the appropriate hardware to connect directly to each
other via Wi-Fi without an intermediate access point.
As was already suggested, sockets are the easiest way to accomplish this if your devices are all connected to a network.
There are things to accomplish here:
Use Network Service Discovery to find devices running your app
Connect to other instances of your app using a socket
For a complete tutorial you can check this out
ShortAnswer: Yes
Data can be sent directly.
In order of range:
1 Bluetooth
2 wifidirect
3 maybe.. GSM hardware direct?
After that, options again in range order:
4 tether or network
5 Internet
The android NSD API is meant to do the exact same thing you are trying to achieve! The example bundled with SDK is self explanatory!
please check:
Android NSD API example

Android p2p GPS app

I am looking to implement a cloud application that allows one to save contacts and if the contact also has the app on, see on a map where the contact is (if in close proximity to you).
I've been looking around towards how to do so and the first step is to establish a connection.
For my purposes, a centralized server to which apps connect and fetch repeatedly updated database information about other users is unsatisfactory as this is too "centralized" for a cloud app.
I've some experience with Bluetooth but in my opinion and experience, bluetooth is not practical as the two devices must then be in very very close proximity with each other.
Thus my question is this, how do android phones connect p2p without the use of local wifi? If that is even possible?
Thank you for your time
Thus my question is this, how do android phones connect p2p without the use of local wifi? If that is even possible?
Yes, via Bluetooth where available, but it will probably not meet your needs. So, in practice, the answer to your question is no. You will need the local wifi.
That being said, you could attempt multicast on the LAN to detect other connected devices enabled with your application. If you want more than LAN, you will need a fully fledge solution including super peers and a P2P framework, like JXTA

Android Wifi direct multiple connection ad-hoc

I try to create an ad-hoc network between many Android devices, but I can't find documentation to do that.
I thought Wifi direct could work for what I want, but is it possible to have multiple connection on one device ? I saw that we could do a device acting like an access point and communicate with many devices, but can we communicate from one client device to two access point devices ?
I have for example 3 devices: A -> B -> C
The "A" device need to communicate with "C" device but he's too far away, so I want to have ad-hoc wifi direct connection between A&B and ad-hoc wifi direct connection between B&C, so A can communicate with C. It should also work with more than 3 devices.
Thanks !
Here is the link to the Wifi Direct Demo http://developer.android.com/resources/samples/WiFiDirectDemo/index.html
I have been working on establishing ad hoc communication over Android phones for a month. I am trying to create an app that could work without having 3G or access point. Main idea is to let the clients to be able transfer voice or data in a close range.
There are some guys implemented a basic system regarding almost the same topic. It basically works with Wi-Fi access point. So you need an access point in order to establish the connection. Although this is not what I am looking for, it might be helpful for others. You might need to contact them for more details.
https://sites.google.com/site/androidwalkietalkie/home
Android does not have support for ad-hoc WiFi at this time -- sorry!
Update (2019): Android has supported WiFi Direct for a while, and this answer has not been updated.
Your scenario would work. A would be able to connect with C as long as B (the group owner) is within range of both A and C.
See Android's developer documentation for more info:
https://developer.android.com/guide/topics/connectivity/wifip2p
At this time only Galaxy S 2 support Wi-Fi Direct
The wifi direct supports concurrent hosting and client capabilities on single interface. Which means, the device will act as an AP, allowing other devices to connect to it as clients, And also connect to another AP as a client. And can share internet connection by driving the internet traffic between the interfaces.
However, current implementations of wifi direct on android are specific to the phone and not part of andorid sdk. So there is not much clarity if they support concurrency. This capability is not limited by hardware.
Ad hoc wifi is disabled in Android. You need to ask Google why they have chosen to do so. If you have access to a device that allow you to install custom Android images, you will be able to patch Android to support it. Or you can root your device and reenable ad hoc Wifi, there are plenty of solutions on the web on how to enable ad hoc on rooted Android devices. This is a software issue, the hardware on every Android device that I know of has support for ad hoc Wifi.
The Serval Project, based in part on WiFi Tether, is the only place I've found this functionality. It's still alpha phase, but seems to be the forerunner in the field. The wiki is much more useful than the main project page linked above, with installation instructions and a bit of documentation.
Serval may or may not be right for your needs, but I felt it should be pointed out that ad-hoc networking is not impossible on Android. It might be better to wait until Google gets around to implementing it as standard API, though (if you believe they ever will :) ).
Well You might be interested in looking at AllJoyn. It is qualcoms SDK for android OS which includes wi-fi peer-to-peer implementations by creating adhoc connections. This is same as Wi-Fi Direct.

Categories

Resources