I am trying to call the localhost in my android application. But unfortunately it is not possible i used several methods like emulator local host
http://10.0.2.2/android/dbconnection.php
and then my network ip address
http://192.168.1.xx/android/dbconnection.php
also
http://localhost:8080/android/dbconnection.php
but nothing is connected to my localhost. For this purpose i refer some stackoverflow answers that is also not working
If you are using the emulator,
http://10.0.2.2:8080/android/dbconnection.php
should be the way to go. If that fails as well, check for typos in the address (maybe it's dbConnection.php), take a look at your log cat and also check if you have declared full internet access in your manifest.
I am also facing the same problem when i worked on localhost. i referred some stackoverflow answer finally i got the solution create a new emulator it works fine in the new emulator.
Related
I am having trouble getting my android app connected to just some particular servlets running on my server. I am getting an UnknownHostException when trying to connect. I assure you I have used the
<uses-permission android:name="android.permission.INTERNET" />
in my Manifest file and have already gone through atleast 5 or 6 similar SO questions.
When I use the URL which is shown with the original exception, in a browser, the servlet page shows up just fine. (Even in the device's browser!)
Note:
I am running this on a physical device
This happens only when I try and connect to some servlets. Not all. (Talk about weird!)
I'll give the codes if you want it.
At last, this was a silly problem.
What I did was, I used just http:/ instead of http:// in front of the URL and when I pasted this in the browser, the browser auto-corrected it into http://. Changing that back to http:// fixed it!
I leaving this here hoping that this might reduce the hours of headache caused by this annoying problem and help someone.
Sorry for the newbie question, but I spent the whole day trying to figure out why the target list remains empty.
This is what I've done so far:
Launched the Weinre host, bounded to my desktop ip adress
(192.168.0.38)
Checked it on Chrome : the host is bounded to
192.68.0.38:8080
Checked that the device is able to access to 192.168.0.38:8080/target/target-script-min.js#anonymous
White-listed both 192.168.0.38:8080 and 192.168.0.38 in config.xml
Added the script call in the index.html
Still the target list remains empty when I launch the app on the device from ADT...
What should I do next?
Thanks!
___ EDIT
I tried the demo, and it's working!
So what makes the difference between calling the script from a demo file, or from the application?
Turns out for me, the problem was that the mobile device silently switched over to another Wi-Fi network (than the one my computer was on), thus rendering the Weinre JS Script unreachable from within the app.
It's different than the issue described above (since, for Yako, the example scripts were working fine), but thought it could help somebody someday.
My issue was that I kept trying to access a page anchor. Apparently that doesn't work too well so I have to load the page first with no anchor, then add the anchor separately.
Finally, it's working!
It seems I only had to wait a little bit after app initalization!??
For all of you who still have to use weinre and have the same problem, I just want to share my mistake:
I did not whitelist my IP-address in the config.xml
maybe some of you have the same mistake.
I came to seek help, I have search, read and tried several solutions I came across, but none seem to work for me,
I can't access my local website from the android emulator, using "http://10.0.2.2", but I tried it on other computer, and it works, I'm using Android Webview, does it have something to do with htaccess? How can I determine which htaccess is settings is in effect?
Is there anything I've missed to make it work, btw, when I try to access the local page using the builtin browser, I can access it without any troubles.
Do you have the android.permission.INTERNET permission in your manifest? For more information see: http://developer.android.com/reference/android/Manifest.permission.html
My colleague have disabled dns caching in Android application. But we have to check whether we really disabled caching. Do you have any ideas how to check it?
We used the next commands to disable it:
System.setProperty("networkaddress.cache.ttl", "0");
Security.setProperty("networkaddress.cache.ttl", "0");
ps: this disabling is needed for automation tests.
Its working.
I've tested it connecting to a servers url with a dynamic IP.
Before it took 2 hours until it could resolve the changed IP. after adding your code it resolved the new IP imm
My guess is that Yaniv is seeing what Yaniv wants to see: If you grep the Android source code for networkaddress you can see that it only appears in some Apache Harmony test code. That is, it doesn't seem like Android uses the networkaddress.cache.ttl setting(s).
Android not support that way, change dns cache when android 4.0, can't change dns ttl
it is answer
i am developing phone-gap app in android. In app I am calling a servlet returning JSON. Under app code I am calling following method through javascript in index.html
JQuery.getJSON(servleturl,function(data){alert(data)});
When running in emulator the alert is getting displayed, but data is always null. However if i launch the index.html (main application file in phonegap) from browser, I am able to get Json.
same thing happens even if I use $ajax.
please help me and let me know what I am doing wrong.
A little bit later, but I had the same problem today, and I've solved it, so if you didn't sort this problem this would help.
So, the problem is not in JSON or in the phonegap, but it's in the AndroidManifest.xml file.
You should have a tag like this:
<uses-permission android:name="android.permission.INTERNET" />
this should allow your application to work with Internet. Without this connection to Internet from your application is forbidden. That tag need to be placed right after the start tag.
Check Phonegap sample manifest for full list of possible permissions.
hope this will help to someone.
I fixed up (read made the changes to get working under a newer version of node.js) a little tool called ibug that John Boxall wrote that I found useful for debugging on the phone (since there is no real way to do it except debug.log and looking at XCodes console window. Its basically a stripped down firebug lite, and its hosted on github as ibug. Hopefully it will help you figure out why things aren't working.