Android service that only allows WiFi Internet connectivity for installed apps? - android

is there a way I can force Internet access for installed apps
to only go through wifi, ie prevent any data transfer via the radio/3G
interface?
I'm looking for a solution that wouldn't require a jailbroken phone,
so I guess fooling around with iptables might be out of the question.
Please let me know, thanks.

I suppose you could use the solution for this question:
Android: Stop/Start service depending on WiFi state?
You'll need to modify it a bit, but that'll let you know when WiFi is activated and deactivated. I'm not sure what the purpose of your application is, but I certainly wouldn't recommend doing it.

Related

File transfer without asking permission everytime

I am developing an android app in which I want to send an image file between two devices very quickly. It's like the image will run from first to second, second to first and so on.
The app will ask ONCE for the permission to use your Bluetooth (or if there is any other service to use) at the time app is started, but not at the times when the file is transferred.
I searched for it and got to know that file transfer without permission, is not permitted in Android4+. so Is there any way i can achieve it?
If it can be achieved with any other service than Bluetooth, I would like to know. Any suggestions will help. Thank you.
There are two ways you can do it. One is Bluetooth for sure.. Use InsecureRFcomm connection for creating bluetooth socket look at the answer of this question How to create Insecure RFCOMM Socket in Android? .. Also I would like to tell you.. if both the android devices have your app then you need not ask permission everytime... and. in my case. I even did not aske permission to switch on the bluetooth... I used bluetoothAdapter.enable(). .. (It is not advised though)
the other way is Wifi p2p or wifi-Direct ..You can find it on the developer's guide..http://developer.android.com/guide/topics/connectivity/wifip2p.html I haven't used it. Please let me know if you do.

Android WiFi Direct - Connect without prompt?

Is it possible to automatically connect two devices without requiring the user to tap an "accept" button when creating an Android WiFi Direct P2P connection?
A bit late response but it might help someone searching for an answer.
Yes it is possible by creating Access Point as #hengsti said, but I would suggest to consider using Google Nearby Connections API instead (Nearby -> Connections API). It is much more reliable and easier to use.
Check this link https://groups.google.com/forum/#!topic/android-platform/hN5WfXRzXpI it might help. He has conducted a few experiments on the way of connection , it might help
It is possible, but your device must be rooted. See my answer to the closely related question: https://stackoverflow.com/a/18629705/1041475.
Much more complicated alternative is to build your own ROM with that patch already applied.
Once the two devices have been connected at least once, the confirmation is no longer necessary. Otherwise the other two answers cover it quite nicely, it is not possible to do so at the moment, and probably never will, at least according to this "bug" report, which was deemed obsolete by one of the Android project members (see post 46).
In the mean time this is possible, by calling creategroup(), where you instantly become goup owner of the wifi-direct connection. This creates an Access point which an client can connect to. The client can fetch the SSID and Password with a WIFI_P2P_CONNECTION_CHANGED_ACTION event, see this blog and code example.

Is there a way to make an android device answer to icmp pings addressed to the broadcast address?

I would like to programatically make my device answer to broadcast pings (i.e pinging 192.178.1.255) while connected to a wifi network.
Is there a way i can do that ? Maybe a listener that will ping back, or a flag to set somewhere?
Thanks.
Is there a way i can do that ?
In short: Yes. But it will take some good effort to integrate the necessary components.
The key problem is that you need to listen for ICMP network packets. Such functionality is not accessible from Java and would require either JNI code or an external program. (To my knowledge, it also requires a rooted device.)
You will need a library or program that can process network traffic, such as Jpcap (which would require some modification to work on Android). You could also install and run an instance of tcpdump in the background and parse its output.
It's not possible for an app to send/receive ICMP Echo Requests on Android. (Maybe there is a way on rooted devices)
But if your basic goal is to implement some kind of local device discovery functionality (and your code runs on all devices), you can use UDP broad/multicast messages instead.
I know this question is quite old now, but I came across this looking to for an answer and managed to work it out myself.
What I did was download a root file explorer (I used Root Browser from JRummy Apps) and navigate to /proc/sys/net/ipv4 edit icmp_echo_ignore_all so that it is a 1-line, 1-character file that simply says 0 (when I opened the file, it was set to 1)
No reboot, ICMP requests started working upon saving.

Android - Disabling 3G and Enabling 2G

I found a lot of posts where people say you can't manage 3G/2G connection switch, but we all have widgets and such and I wanted to know if there is A way (even a console command) that would let my app automatically enable 2G connection, or a shortcut or just anything, because I'd need to disable 3G connection and let the user reactivate it. Is it possible in any way? I don't mind if a rooted phone is required :)
I know there isn't such an API, but there shall be a way in which widgets can work, and I'd love to know it :)

How to force a GPRS connection instead of 3G or Wifi?

I am writing an application where I need to have specifically a GPRS connection, even if wifi or 3G (or better) is available. I have figured out how to disable wifi (by using WifiManager), however, I can't seem to find out how I can programmatically disable 3G and only use a GPRS connection, with equal effect as changing this manually in the device settings.
Is there a way to do this with code?
UPDATE: What I am looking for does not necessarily have to be in the public Android APIs. It might as well be in one of the undocumented APIs, or as a last resort, device-specific APIs, I just need something that works. However, I'd rather not have to root a device to use these functions.
The issue is not just private APIs but that a 3rd party APK cannot get permission to modify such a setting.
As a result, doing so would require a rooted device in addition to reverse engineering private interfaces.
as far as i know changing the type of the mobile network is not possible out from an app.
In android framework, TelephonyManager is the object providing Telephony service to android application.
see http://developer.android.com/reference/android/telephony/TelephonyManager.html
The service do provide several methods to know state and information of your physical radio component.
But there is no way to modify the way the physical radio component of your device do its job. Its a private logic of your device manufacturer that try to do its best to comply radiophony industrial standard and provide the best end user experience quality
This is an public api android point of view (over dalvik) answer, do not answer in context of private android api, nor native way nor root privileged way.

Categories

Resources