Farshad Hassani
Farshad Hassani

Reputation: 81

Android studio volley bad response

I'm trying to send a simple request to my server and show the response in a textbox. my server code is a simple echo("hello"); . my app has a button to send request and two textbox, one for showing responses and one for showing errors I expect that my app show "hello" in response textbox. but I receive this:

<html><body><script type="text/javascript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("5938ce5f20b9041ea269c702ae8441d9");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://login.venci.ir/?i=1";</script><noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript></body></html>

my "MainActivity.java" code is:

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button btnSend = (Button) findViewById(R.id.btnSend);
    btnSend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(MainActivity.this, "Req Sent", Toast.LENGTH_SHORT).show();
            sendReq();
        }
    });



}

public void sendReq (){
    String url = "http://login.venci.ir/index.php";
    StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String s) {
            TextView txtR = (TextView) findViewById(R.id.txtR);
            txtR.setText(s);
            Toast.makeText(MainActivity.this, "Responce", Toast.LENGTH_SHORT).show();
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            TextView txtE = (TextView) findViewById(R.id.txtE);
            txtE.setText(volleyError.toString());
            Toast.makeText(MainActivity.this, "Error", Toast.LENGTH_SHORT).show();
        }
    });
    RequestQueue queue = Volley.newRequestQueue(this);
    queue.add(request);
    queue.start();
}

}

what's wrong with my code or my server?

Upvotes: 2

Views: 297

Answers (1)

Farshad Hassani
Farshad Hassani

Reputation: 81

this error is because of my server. I used free hosting for my server and this error is made by that. Solution: Use payed hosting only!

Upvotes: 2

Related Questions