Menu

Home

John Ambeliotis

Welcome to jaQR wiki!

This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: [SamplePage].

The wiki uses Markdown syntax.

Project Members:


Discussion

  • John Ambeliotis

    John Ambeliotis - 2014-09-17

    Android Example Code

    public void startScanner() {
        Intent intent = new Intent("net.jambel.jaqr.libjaqr.SCAN");
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        startActivityForResult(intent, 0);
    }
    
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        if (requestCode == 0) {
            if (resultCode == RESULT_OK) {
                String contents = intent.getStringExtra("SCAN_RESULT");
                // Handle successful scan and send scan result contents to web service
                AsyncCallWS task = new AsyncCallWS();
                task.execute(contents);
                Toast.makeText(this, contents, Toast.LENGTH_LONG).show();
            }
            else if (resultCode == RESULT_CANCELED) {
                // Handle cancel
                Toast toast = Toast.makeText(this, "Scan Cancelled", Toast.LENGTH_LONG);
                toast.setGravity(Gravity.TOP, 25, 400);
                toast.show();
            }
        }
    }
    
    private class AsyncCallWS extends AsyncTask<String, Void, String> {
    
        //@Override
        protected String doInBackground(String... params) {
    
            return getWsResult(params[0].toString());
        }
    
    private String getWsResult(String _Value)
    {
        final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
        // for non SSL
        //final String SOAP_ADDRESS = "http://www.my_domain.com/ws/my_web_service.asmx";
        // for SSL
        final String SOAP_ADDRESS = "www.my_domain.com";
        final String SOAP_FILE = "/ws/my_web_service.asmx";
        final String SOAP_ACTION = "http://www.my_domain.com/my_web_method";
        final String METHOD_NAME = "my_web_method";
    
        SSLConnection.allowAllSSL();
    
        SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, METHOD_NAME);
    
        // Web Method parameters
        request.addProperty("say_hello", _Value);
    
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
    
        envelope.setOutputSoapObject(request);
    
        // Choose Method
        // Clear text
        //HttpTransportSE transport = new HttpTransportSE(SOAP_ADDRESS);
        // SSL
        HttpsTransportSE transport = new HttpsTransportSE(SOAP_ADDRESS, 443, SOAP_FILE, 5000);
    
        Object response = null;
    
        try {
            transport.call(SOAP_ACTION, envelope);
            response = envelope.getResponse();
        }
        catch (Exception exception) {
            response = exception;
        }
    
        return response.toString();
    }
    
    //@Override
    protected void onPostExecute(String result) {
        // Handle the result!
        Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
    }
    
     

    Last edit: John Ambeliotis 2014-09-17
  • John Ambeliotis

    John Ambeliotis - 2014-09-17

    ASP.NET web method

    [WebMethod]
    public String my_web_method(string say_hello)
    {
        return "Hello " + say_hello;
    }
    
     
  • John Ambeliotis

    John Ambeliotis - 2014-09-17

    How to install the library

    1) Copy 'libjaqr.aar' to your '/libs' directory on your Android project.
    2) Create corresponding dependency to gradle.

     

    Last edit: John Ambeliotis 2014-09-17

Log in to post a comment.