• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Using my Android app. on a different network?

simhamed

Lurker
Hello guys!
I'm not here for the code but more for your ideas/suggestions.

So here's the problem : I managed to make this Android application that can show my DB's records and works just as I wanted.
The code uses a PHP script to connect with a local mySql database and a JSON parser is also used.
Of course, the application works perfectly in my internet connexion since I forwarded the port 80 to my computer by loging into my router.

http://img135.imageshack.us/img135/6646/52938713.png

Now, I'd like to make it... more global?

I'd like for example to use this app in my university's network.
But I can't access the university's router... So how can I use my http://ipaddress/temperature.php script without being able to forward port 80 anymore? And is there any "static" IP adress I can use? (like, not having to change my IP adress on the code everytime I connect to a different network)

Code:
try{
     //commandes httpClient
     HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("[B]http://81.xx.xxx.xxx/temperature.php[/B]");
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();
     }
     catch(Exception e){
      Log.i("taghttppost",""+e.toString());
            Toast.makeText(getBaseContext(),e.toString() ,Toast.LENGTH_LONG).show();
       }
Any ideas guys how to proceed please ?
Is there a way I can still use my PHP script on any network?

Thanks in advance for any help!
Any suggestion is welcome to solve this issue.

PS : The code used looks a bit like the one here
 
I am confused. you should be forwarding port 80 on the computer serving the PHP file and database. It shouldn't matter what router your client device is connected to.
 
Well... Actually, you're right! xD

When I used my external/internet IP address (like the one found on Adresse Ip - Mon IP - Localiser une adresse IP), it didn't work...
But then I chose the one from cmd/ipconfig and it's working! My bad!
Thanks a lot!

But why on my home's network I have to use my external IP address to make it work, while on the university's network I can just use my local/ipconfig IP address?

Then here's another question: Is there any (easy?) way I can use my app on every network without having to change the IP address on the Eclipse's code everytime?
Like using a fix IP/link etc for every network?
 
You should be using your public IP (the one from the link you posted) always. If it works from outside the network, then it should also work from inside the network.
 
Back
Top Bottom