I want to connect to a specific network (according to the network's name) from the app.
This is so the user doesn't need to open the system's networks-list.
If this is not possible, how to open the system's networks list from the app.
You don't need to ask the user to select a network from within the app. Simply allow your app to use the network to which the phone is connected already. To do this, you need to add network permissions.
Here you have everything you need :
https://developer.android.com/training/basics/network-ops/connecting.html
Related
I have seen in many apps that when VPN is connected you can get inside the app and if you are not connected you can't get in.
How can I do this with Java programming?
Write your program like it would access any other local network resource. Once the user connects to the VPN, the network resource will become available and is handled further down the stack. No need to account for a VPN programmatically in your application.
Here is the current scenario:
I have two(2) Android phones.
Android Phone 1 as the server phone.
Android Phone 2 as the client phone.
Here is what I want to do:
I want to create an Android-based app (E.g. Student Information app) where it will have basically two (2) modes:
Server - for adding, editing and deleting data on a local database.
Client - for viewing data from the database of the server.
The app will be installed to Android Phone 1 and set to Server mode.
The app will be installed to Android Phone 2 and set to Client mode.
I want to ask these questions:
I want to locally host the database of the Server app, so that Client app will be able to view the data. Is this possible?
If yes, how can I do it?
Note:
I am currently a web developer so I know that connected on the same network is a requirement.
I have implemented the same concept on a medium business where the web-based system is locally hosted so that computers on the same network can access it.
Suggest everything that you want to suggest, except the disadvantage of doing this concept. I am aware of some obvious disadvantages based from my research and willing to face the disadvantages provided that I will be able to implement the concept.
Rooting the phones is an option.
I want to accommodate small-sized business that is why I want to use Android phones rather than using Desktop Computers/Laptop.
I have read similar suggested questions here based on my title.
We have done the exact same thing in my company. The way we solved this is that the server exposes a service using the Android NSD API, so the clients (using the same API) can find it on the network. And after a client has connected to the server, the server sends its database file (yes, the .db file in /data/data/...) to the client via OutputStream. When the client receives the entire database and checks for its integrity, it copies it to its own /data/data/... and restarts part of the app.
Android NSD
I'm looking for guidance on how to achieve (build) the following:
I have a native App (supported on both Android and iOS)
I have a user 'A' who has the app installed on his phone.
I want another user 'B' to be able to remotely (on a browser) be able to "view" or "take control" of the app being used by user 'A'. So, User A could say "Share with User B" and User B starts seeing a virtual view of the app on User A's phone, and follows as User A navigates around the app.
Basically, some sort of screen sharing on phone, but only limited to my app.
Note that I do not want the user 'A' to install any separate app to share my app. It should be a capability existing/built within my app itself.
To achieve your goal there are smaller problems to take care about, from screen change detection to P2P communication between network nodes.
For iOS there's a Hierarchy Viewer github project that setups HTTP service on device, allowing to preview snapshots of app window using a web browser. Making use of that, you'd still need custom protocols to notify about user touch events and screen changes, which in turn requires effective screen change detector.
Note that this solution assumes no NAT stays between controlling and controlled devices, which is usually a case for local networks. To use the Internet as a medium, you should consider P2P protocols capable of NAT traversal (reffer to STUN protocol for endpoint address recognition and hole punching as a NAT traversal technique).
As a suggestion, how about this? Please note I'm not into this myself, so I might be suggesting something very hard to do.
Create a website that shows the same information as the phone
Make the app have a "server" component
Have the website authenticate and connect to the phone
Have the phone to send over the data from the app to the website, which can then show it in the appropriate fields/positions.
I think what you're looking for is some kind of VNC-like server that would be integrated into your application and serves the content of your application ui on the network. It should be technically feasible, yet it certainly won't be easy !
There are several VNC servers for android ; most but not all requires root access though, probably because they serve the phone screen and not one specific application.
I wanted to code a web application, where one user can choose a file and other multiple users can download that specified file off of that user's computer. That user would have to leave his computer on and leave the web page open.
I dont want to have a big main server that has to handle all that traffic. That user's computer is the server, persay. I understand I'll use torrent.
All this has to be done on a website.
Will a web socket work?
Please and Thanks.
This really isn't possible for a variety of reasons:
Firewalls / NATs
Dynamic IPs
No "server" running on the user's machines
Permissions on the user's machine
What happens if the user simply deletes the file on their machine?
To actually make it work you'd have to:
Convince the user to install the app on their machine (you'd need a windows/linux/... EXE)
Get the user to open a port in the firewall (or use some library to enable NAT passthru)
Have the user's PC ping your server in the event the user's IP changes
On the server side, you'd have to keep several database tables, here are few I can think of off the top of my head:
A user's table (user ID [PK], Current IP, Communications Port, (maybe some other tracking things))
Available downloads table (download ID [PK], user ID [FK])
Then when someone wants to go off and download, you have to (probably) launch your app with the requisite arguments (remote user's IP/port/file ID) and have that do the work of the download.
This is by no means an easy feat.
If by WebSockets you mean the HTML5 variety, I'd stay away from that. http://en.wikipedia.org/wiki/WebSockets#Browser_support
The the computer that has to stay on, is basically your server. Even if it isn't a big server somewhere.
My suggestion would be to install apache or some other small web server on each users computer and have have a dyndns address for each computer so you can find each other. it would be much easier than coding something. especially if it has to be through a web page.
You could use a c# client library to interface to bittorrent or etc and use this mode to upload/leach. As far as NAT/Firewall issues go they are well documented and a function of the protocol being used, ie deal with it.
My Java.app broadcasts a packet on the network as soon as it starts up. Everytime I start this app, the Mac asks me do I want to allow network connections blah..blah.. Can I use info.plist or something to allow network access to this app and not bother the user who has trustingly downloaded and installed my app.
Thanks
You can choose to allow incoming connections for specific services in System Preferences > Security > Firewall.
Addendum: You application will appear only if the user has chosen to "Set access for specific services and applications." It will be added the first time the application attempts to open the port.
Addendum: The application appears with the name java in the Firewall pane. Once the user chooses to accept or deny, the dialog ceases to appear. This simple example is convenient for testing.
If you codesign your app (using the same key across updates) it should work properly with the app-specific firewall on. It seems to be a bug on Apple's side that unsigned java apps are prompted for allowing network connections (even if they don't try to listen to the network) every time they are run.