Accessing Internet through Android Application - android

We, two team mates and I, are trying to access a WCF web service through an Android application. We are using a JSON for the transport of objects. We have tested that the service can be called through HTTP via google chrome, internet explorer and the android browser on the emulator.
We have already set up the internet permission in the android manifest using
<uses-permission android:name = "android.permission.INTERNET"/>
We are using the HttpClient and the HttpResponse objects, to connect to the WCF Server.
Currently we are attempting to access the server both locally on the machine that the emulator is being run on, and one that has been hosted on the local network.
Our problem seems to be that we cannot connect to any server through our app, whether it is our server we are trying to connect to, or any other server.
We have already tested the server connection with a windows phone program using http, which seems to work fine.
Are we missing something obvious? We really do feel like we are banging our heads on a brick wall.
Many thanks for any advice given and if any more information is needed please feel free to reply.

Use 10.0.2.2 as IP for the server running on the same machine as the android Emulator...

Try using Traceview http://developer.android.com/tools/help/traceview.html to find out where the problem is happening. You can use it to create a trace file showing the status of the network connection and where it is failing.

Related

How to connect an android app running on a device connected via ADB to hit REST API on local server?

I have a multi-tenant web app like
http://xxxxx.constant-domain.com:8080/
in my host file
127.0.0.1 xxxxx.constant-domain.com
The device that has the android app running is connected via ADB which calls my webapp's Rest Apis to get and send data and
It runs fine on dev and prod environments like
http://xxxxx.dev.constant-domain.com/get-data
but the problem is I want to debug it on my local server. I tried adding the given domain as base url but it doesn't work.
I tried adding http://localhost:8080/ as well but it doesn't work.
I tried looking for questions here but didn't find anything that would help.
I'm using retrofit for Api calls.
Any help would be appreciated.
First of all, make sure that your local server and your device are using a same wifi. And then find out the option to put your local server online. There is an option in Wamp Server to put it online. I don't know which software you are using to setup apache or any kind of server on your computer.
And then you will be able to access your local server by ip address. Also there is an option to edit virtual hosts of your server to allocate a specific port that the app can connect.
It doesn't matter whether you use Retrofit or Volley or Okhttp or any other things. You need to setup your local server to be online within your local network.
I figured it out. All I needed to do was to set my private Ip as
http://192.168.8.400:8080/get-data
Hope this helps anyone who is in this situation.

API Calls connecting to intranet server not working in Android Emulator

I am trying to connect to the local intranet server from my android application. The api calls work fine in the postman and other clients. But, when I am trying to do the get or post request to the server from android emulator, it's returning response code "503" (meaning host is not reachable).
The APIs are hosted in the server system which is in the local network. I have tried adding proxy, DNS settings, still no use.
I am stuck on this issue since a week now.
It would be great if someone could help on this!
you need to set URL as 10.0.2.2:portNr
portNr = the given port by ASP.NET Development Server

Android login while working with mobile phone but working fine in emulator

I developed android app using this website.
http://www.coderzheaven.com/2012/04/22/create-simple-login-form-php-android-connect-php-android/
but i am able to login in emulator but when i am trying in my mobile it is not showing anythings. how to over come that.
I had the same problem. The problem might be due to Certificate signing at the time of connection or proxy settings or maybe IP or maybe something like KNOX agent that might stop connection. I started using jdbc and it worked for me. It is easier than php. This might help you JDBC connection in Android.

My Android project won't use VPN

I have a simple app that tries to access an API from a remote server. For testing, I need to use a VPN in order to access it since it is blocked in my current location. When using the browser on the phone, I can get the JSON response I need but when I run my app, It doesn't seem to use my VPN because the JSON response is not the same. I'm using the built in VPN of my test device which can be found in the settings. Any ideas about this? I'm using volley for request.

does anyone had success in posting from android emulator to GAE?

does anyone had success in POSTing from android emulator to GAE? I am trying and I am getting Unknown Host Exception.
Do I need to do some settings in emulator? Please help me. I am using HttpClient and HttpPost, and also set uses INTERNET permission.
I did post to GAE in an application I wrote about a year ago at the university, but didn't have any special problems. What do you mean exactly by posting to GAE? Posting to a webapp deployed on a publicly accessible GAE? Or behind authentication? Or locally on your development environment??
If you want to access GAE running locally on your development environment, you need to use this IP: "10.0.2.2" which represents your local machine, basically your webapp would then be at http://10.0.2.2:8080 (see my post here for more details about that)
Otherwise, if you have issues with Google Authentication from your mobile Android app to a GAE hosted application, it is always good to take a look at open source apps which do the same and see how they handle it. Here are two which came just to my mind..
http://code.google.com/p/chrometophone/
http://code.google.com/p/android2cloud/

Categories

Resources