samedi 4 juin 2016

Ptz link not working from Android Source. Perfectly working from Web Browser

I am working on controlling my TP-Link SC4171G PTZ controls in android. The urls for controlling ptz is : http://admin:admin@IP/cgi-bin/operator/ptzset?move=X where X could be up, down, left, right, upright,upleft, downright, downleft. here admin:admin reflects username:password.

When i put the following url in browser address bar it works perfectly but when im doing it with HttpClient get request it just wont work.

My code is:

 public void CameraControlManager(final String Direction)
    {
        Thread thread = new Thread(new Runnable(){
            @Override
            public void run() {
                //code to do the HTTP request

                try {
                    GET("http://ift.tt/1UosAno"+Direction);
                }catch (Exception e)
                {
                    Toast.makeText(DoorControl.this,e.getMessage().toString(),Toast.LENGTH_LONG).show();
                }
            }
        });
        thread.start();
        //"http://ift.tt/25G8eBR"

    }

    public static void GET(String url){
        InputStream inputStream = null;
        String result = "";
        try {
            final HttpParams httpParams = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParams, 30000);
            HttpClient httpclient = new DefaultHttpClient(httpParams);

            HttpResponse httpResponse = httpclient.execute(new HttpGet(url));
            inputStream = httpResponse.getEntity().getContent();
        } catch (Exception e) {
            Log.d("InputStream", e.getLocalizedMessage());
        }
    }




Aucun commentaire:

Enregistrer un commentaire