Android-how does the android background receive the getpost data sent from the android client to the background written by php?

Source: Internet
Author: User
For example, you can use the get request '{code...}' and then use the php background to accept the data sent by the android client.

For example, use get request'

public class MainActivity extends Activity {private EditText name;private EditText age;@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);   name=(EditText) findViewById(R.id.editText1);   age=(EditText) findViewById(R.id.editText2);  Button regist= (Button) findViewById(R.id.button1);  regist.setOnClickListener(new OnClickListener() {        @Override    public void onClick(View v) {        String url="http://testshitou.sinaapp.com/http.php";        url=url+"?name="+name.getText().toString()+"&age="+age.getText().toString();        new HttpClentThread(url).start();    }});}

}
`

Then how does the php background accept the data sent from the android client?

Reply content:

For example, use get request'

public class MainActivity extends Activity {private EditText name;private EditText age;@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);   name=(EditText) findViewById(R.id.editText1);   age=(EditText) findViewById(R.id.editText2);  Button regist= (Button) findViewById(R.id.button1);  regist.setOnClickListener(new OnClickListener() {        @Override    public void onClick(View v) {        String url="http://testshitou.sinaapp.com/http.php";        url=url+"?name="+name.getText().toString()+"&age="+age.getText().toString();        new HttpClentThread(url).start();    }});}

}
`

Then how does the php background accept the data sent from the android client?

Although you do not know whether you are writing an APP or a server, the get post request is platform-independent.
Backend interfaces written in Python, C ++, PHP, and Java can directly send requests to the server.
Whether it is Android, Web, OS X App, or iOS App, the client can send requests to the server.

The background get post Reception has nothing to do with the android client. You can only get post in the background. The client knows how to do the rest, whether it is Android, iOS or WP.

The question should be changedHow php receives get/pos parameters sent by the clientIt has nothing to do with android. Enter in the browserHttp://testshitou.sinaapp.com/http.php? Name = My name & age = 18Is equivalent to a get request.

For example, to receive the name parameter_GET['name']Or_POST['name']You can get

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.