Enable 3G and WiFi Simultaneously - android

Does anyone know if its possible (programatically) to enable both 3G and WiFi to be used simultaneously, both receiving and sending packets?
I have seen various other questions on here, but with the Tethering ability inside Android now, I was wondering if this is a possibility? This has to be on a standard/stock device, and no modifications via root to the OS.
Thanks
Adam

I don't believe it is, as soon as wifi is turned on, 3g will automatically disconnect. As far as I know there is no way round it.

The only way you can achieve this is by using a APN name with the HttpConnection. This is possible in Java ME, Please visit this answer, however i have never tried it.
You need to check for the active connection, if not active first one the switch to the next connection.

public void shutup(){
SuDroid cmd = new SuDroid();
cmd.sh.runWaitFor("svc wifi enable");
cmd.sh.runWaitFor("svc data enable");
cmd.sh.runWaitFor("svc data prefer");
}
Using SuDroido

Related

Which method is called when someone tries to connect using WifiP2PManager.connect(Channel, WifiP2pConfig,ActionListener)?

I am tring to setup WIFI P2P on 2 devices using
manager.addLocalService(channel, service, ActionListener)
and then connect both devices using
manager.connect(channel, config, ActionListener).
I would like to know which method is called before the popup to accept/reject connection is shown on the target device. All I was able to find was onConnectionInfoAvailable(WifiP2pInfo p2pInfo), but it is called after the connection is established.
I basically want to receive the "instance name" of the device trying to connect to me using WIFI P2P and then reject the connection request without showing system dialog(that allows the user to accept/reject connection).
I can't anything that can help me do this on docs or any other place. If anyone knows how to do it or can point me in the right direction then please let me know.
I solved it. I can put the instancename and devicename (of device I want to connect to) in Map that is passed when setting up service. From other device I can retrieve map of all devices available using this and find the instancename of one I need.

How to disable Wifi when not used in background android?

I want to disable the wifi when not connect to any network. It will be running in the background and disabled anytime when wifi are enable and not used. How can I do that? Please give me some advice. I have to use Foreground or Service/ Broadcast Receiver.
You may be interested in Tasker. It can automate basically every setting in Android.
You can make a profile State> Variable Value> %WIFI=on Action: If "Wifi Info" %WIFII !contains "CONNECTION" then Net> Toggle Wifi> Off
You can also do this in Java with a bit more work. I can provide details on that if you request.
And also if you're lazy you can download neat little apps that take care of it for you: Auto Wifi Off
Hope that helps

Android Preferred Network List

I was under the impression that wifiManager.getConfiguredNetworks() returns the PNL of the current device, however when I click on - forget network, wifiManager.getConfiguredNetworks() still keeps that network but just removes the connection details(like security, password etc.)
Is there anyway knowing which SSID(or BSSID) is actually in PNL? (i.e my device can automatically connect to it)
I found out that this problem appeared only on specifics networks, while in others clicking on forget network actually removes the network from wifiManager.getConfiguredNetworks().
I also found out that the only things different are allowedKeyManagement.cardinality and LinkProperties (which is hidden on Android), so I used an if statement on the WifiConfiguration(=configuredNetwork):
if(configuredNetwork.allowedKeyManagement.cardinality()==1)
wifiManager.removeNetwork(configuredNetwork.networkId);
wifiManager.saveConfiguration();
break;
And for some reason it worked. If anyone have an idea whats cardinality stands for or have a better way of doing this please share.

Android bluetooth discoverability

I'm developing an Android app that has to exchange some data through BT by automatically create a communication between two devices. To do so the only way (I've found) is to first make the device find each other and then negotiate a master who will open a ServerSocket and host the connection.
My problem then is how to toggle BT discoverability without prompting the request to the user!
I've searched the net with no success, so I start thinking about possible solution.
First I thought about something like a BroadcastReceiver that would catch the request instead the default activity launched by StartActivity(new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE)), but then I wouldn't know what to do to actually make the device discoverable.
Recently I've thought about hiding or dismissing the dialog raised by the precedent call by automatically selecting the positive button. Once again I've no clue on how to do it!
Any help will be really appreciate, thank you in advance to everyone and sorry for my bad English!
I can't point to any explicit documentation, but I'm pretty sure you're not allowed to silently turn on and off Bluetooth in android. Bluetooth discoverability is something that at the end of the day is always up to the user. To subvert their authority presents a huge security concern.
You can call .enable() on an instance of BluetoothAdapter
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
bluetoothAdapter.enable();

Android detect no data connection

I know there are a few threads on this topic but non of them seem to answer my question. I want to be able to detect when the device has no data connection. I have tried the NetworkInfo route checking if its null, isConnected(), isAvailable() etc. The problem im having is that these work fine (return false or null) when wifi or mobile network are disabled however when they are enabled but there is no signal they return true. Is there any way to detect no data connection due to no signal?
build reciver and catch broadcast
Intent action for network events in android sdk
You could try pinging google.com. If there's no response, you can be fairly sure that there's no connection (unless the user is in a country where it is blocked).
I use ConnectivityManager.getActiveNetworkInfo.isConnectedOrConnecting()
I just tested it 5 minutes ago to make sure, and if everything is working and I then walk away from my house until my router is no longer within range and the network strength indicator on the status bar shows no network, a call to isConnectedOrConnecting() from within an app returns false.
I take it that's not the behavior you are seeing?

Categories

Resources