I am a beginner in Android. I have developed a application that will send location information to server(latitude and longitude value).
I am using Dynamic IP as for now for sending information.
Problem which I face is while using WIFI the information is passed to the server but when I use my Mobile Internet I am unable to send the information to the server. Please help.
Location location = locationManager.getLastKnownLocation( LocationManager.NETWORK_PROVIDER);
if (location != null)
{
String message = String.format( "Current Location \n Longitude: %1$s \n Latitude: %2$s ",location.getLongitude(), location.getLatitude());
Toast.makeText(MainActivity.this, message,Toast.LENGTH_LONG).show();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.1.7/YourPhpScript1.php");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("message", message));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost);
}
catch (ClientProtocolException e)
{
}
catch (IOException e)
{
}`
Here 192.168.1.7 is my dynamic IP address
Its about port redirection problem,
This ip address “192.168.1.7” is you local ip address. Which is just reachable via WIFI but when you use your mobile internet you are not in your local network.You should connect via your external ip address. But your modem probably block all your connection. Redirect port 80 from your modem to your computer and disable your computer’s firewall port 80.
Just check all these step by step.
Your current infrastructure