0
What is it, quiet? I have an Activity that is listing a number of products from a Mysql database. I need you to, when clicking on any of these products, transfer me to another Activity, take the product ID together and, for this collected ID, do a search in Mysql and return me the details of that product. I’m managing to pass the ID to second Activity, I just can’t get this ID, play in php, do the search in Mysql and return the results JSON pro android.
At first Activity I’m managing to pass the ID:
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String pid = ((TextView) view.findViewById(R.id.pid)).getText().toString();
Intent in = new Intent(getApplicationContext(), DetalhesLivro.class);
in.putExtra("pid", pid);
startActivity(in);
}
On Monday, I recover:
EditText txtID;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detalhes_livro);
Intent i = getIntent();
pid = i.getStringExtra("pid");
//Teste para ver se está pegando o ID
//Jogando o ID num EditText
txtID = (EditText) findViewById(R.id.inputID);
txtID.setText(pid);
}
My problem is from now on. I need to play this ID in php and return me the results.
You must use an Asynctask to send this data via POST to the server. In this post the guy did what Oce needs to do, it may be useful: http://stackoverflow.com/questions/17957989/inserting-data-into-mysql-using-http-post-and-asynctask-doesnt-work
– Renaro Santos
vc has the android implementation to communicate with the PHP server ? vc has the implementation that handles PHP requests on the server ?
– Eudes