i'm making and IOT app with Flutter, and i have to connecto to an API. There's a way to force the app to use 4g (or any kind of phone network), instead wifi to make these calls?, any kind of library or so?.
Thanks in advance!
This is something that should be avoided in a production app due to cellular and data fees. Also, there is no system in place to choose between your phone's available connections when making network requests.
Related
can someone confirm, that it is possible to create a web server on android device ( which uses 3G or 4G internet ) and access it via internet ( from the remote PC connected to the internet, not from the same local network ).
I know there already are some web servers for android ( iJetty, nanohttpd ) and the programms like ksweb, so it seems, that it should be possible.
However, I've done some searching in the internet and some people warn, that mobile devices work using NAT protocol, so it would be impossible.
Can somebody resolve the ambiguity?
Thank you in advance.
No, it is generally not possible. The dealbreaker problem is not with Android, but rather that just about any mobile network provider is going to block incoming connections.
For special purposes, you can do things like have the phone contact a publicly visible remote machine and create a tunnel with something like ssh through which inbound connections can then be sent if there is a server program listening on the loopback interface of the Android device. But this tends to be only useful for things like remote testing.
Were you using wifi you could do this, but you'd need to accept that Android is not designed to promise a high availability of any 3rd-party program. You would need a wakelock to keep the processor running. And you may even need to do things like periodically initiate outbound traffic from the device in order to keep the wifi stack/radio in a fully active mode so that it can accept connections.
Generally speaking, data you want to make remotely available from the device should be proactively uploaded to a mutually visible server. If you want to send requests to the device, look at using something like Google Cloud Messaging which is designed to wake up the device and a recipient application on it in order to deliver a brief message.
I want to build an android application that tells how many users are connected to a wireless network? Is there a way to do it? Can tcpdump be used? Please suggest some method.
This really depends on the goals of the App.
Many enterprise wireless access points have a web service and api running on the device that can be queried against. It should be as simple as setting up a http session on the android app and calling the API or web service through post/get calls. even if the AP does not have an api you should still be able to access the routers state through what ever mechanism is used to set it up.
I'm trying to test my iPhone and Android application with poor internet. I remember there was a program I read about a while back that would fake different types of poor internet. Does anyone remember what this program was called or if there is something similar I can use to accomplish this task?
For iOS, as others have said, use the Network Link Conditioner settings under Settings > Developer > Network Link Conditioner.
For Android, just because nobody mentioned this...
use your iOS device to set up a personal hotspot
connect your Android device to the iOS hotspot
I put the Android device into Airplane mode, and then re-enable WiFi (or turn off cellular data, but I find these settings quicker for me to access on my device)
Use the iOS device's Network Link Conditioner settings to adjust the quality of the network
Since the Android device is tunneling through the iOS device's network, it'll be effected by the iOS device's network link conditioner settings.
Super easy, super awesome, and configurable.
The one that I use and recommend is Charles Proxy. You set it up so that your iPhone or Android uses it as the proxy. Then it can throttle your connection to simulate poor network conditions like 3G.
It has a lot of other useful features like being able to track and inspect all your HTTP requests and responses which is really helpful when writing apps that access web services.
For your iOS applications, Apple has a program called Network Link Conditioner for free for Lion users as part of xCode. For your Android apps, you can probably use Netlimiter.
Netlimiter: http://www.netlimiter.com/
A strategy to fake poor internet could be to open up sockets and send data as quickly as you can - the more threads that are doing this, the more of your device's internet access will be taken up, thus leaving less for the app. For example: if you have 1 other thread sending data, your bandwidth will be halved; if you have 3 other threads, only a quarter will be left for your application, and so on...
I imagine that this is the strategy employed by the program about which you read (although there are other ways in which this could be accomplished).
There's the Apple Link Conditioner which is included with all recent installs of the developer tools. It'll be in system preferences once it's installed.
Is there any way to send request from a server to an Android phone? Actually, I want to control an application (enable or disable some features of the application) in an Android phone by a server. Can I use the IP Address of the Android device?. Can anyone guide me.
Thank you!.
Much simpler way is for phone to contact server and ask should features be enabled. You could also use something like this http://code.google.com/android/c2dm/ but I'm not sure if this is an overkill for your use case.
If the above option is not suited for your case then you can create a simple service
for your application and then attach to application.
The service can be a thread which sends requests to the server with some time intervals that you find suitable and can check if there is anything to check and to do for the application.
And also can run in background.
All push services are usually implemented as well concealed polling. Phones on 3G networks usually sit behind NAT proxies and are not visible to outside world. The same holds for most wlan networks - so either use C2DM, or write your own service polling config information from some server provided by you
I'm wondering if, with the G1, it's possible to force the network traffic to pass through the Wifi or through the Cell GSM network. I need to force an application to connect through the tower network to get some login information. Is this possible? Anyone have any ideas as to how this would be possible? I'm trying to accomplish this inside an app with the Android SDK (Sorry I wasn't more clear about that originally)
It turns out to be possible using the WifiManager object to disable and then re-enable the connection. You can block it for the duration of a network call if you want to force data over the cell network. I imagine there is a similar GSM network manager out there which will do a similar task for the cell connection.
I'm assuming that you can simultaneously communicate via either channel, so at some level there aught to be separate network interfaces for each. Since android is based on linux, you could try using ifconfig or a library function to determine which interfaces are available, and which does what. If you can accomplish this, there should be a way to explicitly send/recv via the channel you want (i.e. by communicating via the ip for that interface).
Sorry I couldn't be more specific.
What you are looking for on the G1 is to set the default route. You may do so using the linux utility aptly named route, the default route is going to be to ip 0.0.0.0 and then the gateway.
Not sure if you can do this per application, but you can do it system wide!