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.
Related
I am developing a parental kind of App in which there is a requirement to block specific urls from all the browsers in the Device. I think this is an old question but couldn't find any solution yet on stack.
Do you have any working solutions. Assumption - The device is rooted.
Regards,
sha
I have two resources for you:
Since the device is rooted you can work directly with iptables. iptables will give you very precise control over all coming and going data packets. Check out open source projects like AFWall+ on GitHub for iptables in action.
If you want to be able to run your app on unrooted devices look into creating a fake VPN. You don't send any data to an actual VPN server, you simply use the VPN API to filter all the information coming and going. Check out Disconnect (whenever they actually share their open source code...) or OpenVPN which is what Disconnect builds on.
I'm totally new to network sockets so any help is appreciated.
I'd like to know how to setup a network socket on an Android device and use it to pass data generated by an App to another App on the device.
This is because the App receiving the Data will at some point have to be able to receive data from an external source, so I'd like to build in the basics of this before I get to that point.
Any example code etc. would be great and I'll edit my question as I go if required.
I don't think using sockets can solve your problem. Only one app can be active at a given time, and the connection won't work. Unless you create some sort of service, but this approach seems wrong.
I believe you have 2 basic options in front of you:
A server that both apps communicate with.
Writing information to the disk in a globally readable place.
The server option is better IMO.
I am developing an application. In which the idea is like - i want to connect two devices as two mobile or two tabs or mobile to tab or mobile to server or tab to server. Means i want to send data from one device to other device mostly xml.
I want to connect two devices with out internet and blue tooth, I want to connect them with wifi having no internet. And than want to transfer data.
My point is i am having an application which is used to generate a xml and after generation of xml i want to send it to other device or tab or desktop server on a button click.
I searched on Google and found Ad-hoc network, but it is quite difficult to understand me. Is any other way by which i can easily understand Ad-hoc or other way by which i can connect.
So please guide me what should i do, how can I achieve my task. I need your guidance and suggestions.
Socket connection would be a great idea in your situation, you dont need to have Internet to do so. Here is one of many examples if you google it: http://examples.javacodegeeks.com/android/core/socket-core/android-socket-example/
Hope this helps
You can use iJetty. iJetty can be configured to use in your application and when you start wifi router on one android device another can get connected on that device and if it's your client applciation you can configure it to look on a specific port.
Try this : http://puregeekjoy.blogspot.in/2011/06/running-embedded-jetty-in-android-app.html
You could use Wi-Fi Direct if your version of Android is 4.0 or later and your hardware works with it.
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.
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.