What type of url should android use to send a request to the server?

I am new to Android development. I have recently been working on online Android app projects. To send a post request to the server, I use this type of URL along with the ip address :

public void makeRequest() { InsertData task1 = new InsertData(); Log.d("Arif", "working on pre"); task1.execute(new String[]{"http://209.151.146.23/class/project/subject_request.php"}); } 

When I use a defult url like this, then it also works:

  http://www.sitename.com/class/project/subjec_request.php 

My question is:

What is the difference between these two types of URLs?

Is there a security issue?

And what type of url should use in my project.

Thanks in advance. I am confused by this fact.

+7
android url
source share
3 answers

Difference between

 http://209.151.146.23/~shihabmr/class/project/subject_request.php 

and

 http://www.sitename.com/class/project/subject_request.php 

- host name. Using www.sitename.com instead of 209.151.146.23/~shihabmr ideal as it means that you are not hard-coded for a hostname that could potentially change in the future. When you use www.sitename.com , a DNS lookup request will occur and resolve in the IP address 209.151.146.23 , which is very useful.

In terms of what the balub said in his answer (now missing), he is right to say that you should use POST requests if you do not want to expose the payload directly, but you can still intercept it. Neither POST nor GET are more secure than others, and therefore, if you need security, you must use https .

+2
source share

You have an idea of ​​the difference between the two. Now, to develop an Android application, when you use your computer as a server using software such as xampp, you must use ip. But, when you publish your application or connect to a web server, it is better to use a URL.

+2
source share

Differences between two URLs: 1ΒΊ. The first transition to STATIC IP (209.151.146.23), and the second to the 2ΒΊ domain - I do not know what "~ shihabmr" is

Assuming you don't need "~ shihabmr". You should use the second one, since it is always better to orient the domain than the static IP address, if the IP address of the server changes, you will need to download the new version with a new IP address, but if you use the domain, you only need to change the IP address in the domain

+1
source share

All Articles