-4

I am developing and android app which posts data collected from text boxes in android to a PHP/MySQL database located on uhostfull.com.Now when I am trying to display data from database in JSON format.But neither the request call nor displaying data not working.The code is`

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

public class MainActivity extends ActionBarActivity {
TextView display;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    display = (TextView) findViewById(R.id.textview1);
    String url = "http://xxxxxx.uhostfull.com/get_all.php";
    RequestQueue request= Volley.newRequestQueue(this);
    StringRequest strrequest =new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    display.setText(response);
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    display.setText("that didn't work");
                }
            });

request.add(strrequest);
}
}`

And also I need to send data to a PHP script which inserts into Mysql database.How should I do it.I tried HttpUrlConnection also but data is not transferring.The response is that the POST parameters are empty.How should I solve all these problems???

sasikumar
  • 12,540
  • 3
  • 28
  • 48
Naveen
  • 66
  • 10
  • What is the status for the response of the above request. – Kartheek Jun 06 '15 at 11:02
  • When i am debugging it to try on emulator this is the error Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\jdk1.7.0_25\bin\java.exe'' finished with non-zero exit value 2 – Naveen Jun 06 '15 at 11:21

1 Answers1

0

This might be a little late but the code you posted clearly stated this as a GET request, so if your service is expecting POST, it might be the issue..

If what you are trying to achieve is a GET request with parameters, check this SO question (the chosen answer has an example to get you started).

hope this helps.

Community
  • 1
  • 1
TommySM
  • 3,793
  • 3
  • 24
  • 36