Android DownloadManager doesn't work in some circumstances - java

I'm using DownloadManager (Android, Java) to download files over WI-Fi from a machine in the same LAN. It works flawlessly on most of the phones I tested, but it appears that on some devices the download just doesn't start when WAN cable (Internet) is unplugged from the router (!). Everything gets back to normal on these phones when I'll connect the Internet cable. Other phones download the files without issues no matter if the Internet is connected to the router or not. This is puzzling me for over a week. There are no clues in logcat (download just doesn't start without any error). It's very odd as the Internet shouldn't have anything to do with the downloads. Everything is happening in the LAN. Any suggestions are welcome.

You can set setAllowedNetworkTypes flag.
refer this -> https://developer.android.com/reference/android/app/DownloadManager.Request.html#setAllowedNetworkTypes(int)

As it finally turned out the Fetch library also introduces the same problem. What worked for me, in this case, was crafting my own downloader with AsyncTask and InputStream.

Related

Java - How to ping local IPs to find device with web app?

I have a local device (on my wifi network) that can be accessed using a web browser. However, it regularly changes its IP (it is not fixed, and, unfortunately, can't be).
How could I write a java code, for a small android app using a webview, that could scan my network and find the device's IP, quickly and easily ? Connecting to my router everytime this happens is a real pain...
I'm trying to find the X in the following URL : 192.168.1.X:4600/wui
At least, I think the port (4600) and /wui part should help narrowing the search.
Any ideas ? I am completely lost there, this is way above what I can do with android studio.
Thanks ! :-)

Android connection to router

I am developing an android application and it requests connecting to a linksys router and i wrote a code on java and it is working but when i tried to transform it to an android application i face a timeout exception in this line
JenNetIPNetwork network = service.createNetwork(new InetSocketAddress("fd04:bd3:80e8:2:215:8d00:32:54ff", 1873));
and i am using an emulator.
So is the problem that i am using an emulator not an android device?
And if there is other solutions any suggestions ?
There is possibly 2 problems.
1) your immolator is not connected with router (its your computer.) so try to connect immolator to router or use real device.(this problem has major chance to generate this bug.)
&
2) All networking related stuff in android must be in other thread. try that out.
Try this hope your problem would be solve by this.
one more thing you have to add internet connectivity permission in xml.(if not then do as well)

Android chat working on emulators with redir

I have read tons of this same advices about connecting two emulators using telnet. For example this one: Connecting 2 Emulator instances In Android
I've made all as it is said and nothing works. I have got server app on emulator 5554 and client app on emulator 5556. They are using ports 6000 server app and 5000 client app. What I want is to communicate when this two emulators are open - in both ways.
At the beginning server app shows her ip, and in client app user have to write this ip. That is whole configuration.
As in mentioned post was said I've written redir add tcp:5000:6000 but nothing works. Also when I write redir add tcp:6000:5000 nothing happen. Those apps don't hear each other. However if server is on other device than everything works fine.
Maybe it is stupid question but can someone guide me through this, because I don't know what am I doing wrong.

wake on lan to wake up laptop from android phones

i heard that wol(wake on lan) will only work for desktop systems. is there any implementation in java for wol, so that it works for laptops?(wol is the mechanism of turning on the remote system by sending 'magic packet' to the system).and is there any implementation in java for android phones? i found a simple wol apps in android market, i tried to extract the functionality of these apps, by practically testing them. but no app is working for both desktop and laptop systems.i configured my windows pc, so that it allows magic packet to wake on the pc.but i dont know where its going wrong.
WOL is a BIOS setting that you will need to turn on on the individual machines (I think it is turned off by default). I don't think there is any reason that laptops cannot accept WOL packets.
Here is a simple implmentation of WOL for Java: http://www.jibble.org/wake-on-lan/
It should be easy to port it over to work on Android.
However, you have to note that WOL will only work within a LAN and that the target machines have to be in a specific power setting in order to allow them to turn on.
You have to be more specific. If your laptop is connected over WiFi then there are big chances that it won't work. If your laptop is connected over an Ethernet cable then most probably it will work. You just have to enable WOL from the BIOS, or on some devices it can be also done from the network interface properties.
I'm using WolOn Android app to wake a laptop connected over cable and it works flawlessly both on Windows and Ubuntu.

Why am I getting a UnknownHostException?

I'm trying to instantiate an URL object (in Java) with the address: http://www.cornellrams.com/rss.php. It gives me an UnknownHostException. The site is live and well, but I can't access the feed. Any ideas why it doesn't like me? This is on Android. I do have the internet permission in the manifest.
May be firewall is blocking network connection for the emulator. You need to set /allow emulator to use network connection and also set network connection sharing.
Double check the url ... chances are there's a typo in it somewhere. If not then DNS issue, but you can access the web browser ... so unlikely if you can browse.
Ensure you are using the correct protocol i.e http/https depending on whether you are using ssl
I often get issues with the wifi on my samsung gadgets. not sure what it is perhaps a request gets stuck so I'm forced to turn wifi off then back on again ... it happens a lot (especially with twitter app).
Also make sure that your timeout's are generous especially if using 3g rather than wifi.
I faced same problem once with my emulator. Restarting the emulator helped (maybe also with cleaning build).

Categories