0

So I have been tasked to create an android application that scans a QR code of a WCF Service URL, then call that URL with a username attached as a query string. I have managed to scan the barcode and create the query string which returns a string list of other URLs as it should when used in a browser but I have no idea how to go through with getting that string list inside of android. The code for getting the query string URL is here:

public class MainActivity extends AppCompatActivity {

private EditText inputUsernameField;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    inputUsernameField = (EditText) findViewById(R.id.inputUsernameField);

}

public void scanNowButtonClick(View view) {

    new IntentIntegrator(this).initiateScan();

}

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
    if (scanResult != null) {
        String contents = intent.getStringExtra("SCAN_RESULT");
        String username = String.valueOf(inputUsernameField.getText());

        Uri.Builder b = Uri.parse(contents).buildUpon();

        if (username != null) {

            b.appendQueryParameter("username", username);

        }else{

            Toast.makeText(this, "Please input a Username and try again.", Toast.LENGTH_LONG).show();

        }

        String myUrl = b.build().toString();

        Intent myIntent = new Intent(MainActivity.this, ImageActivity.class);
        myIntent.putExtra("myUrl", myUrl); //Optional parameters
        MainActivity.this.startActivity(myIntent);

    }

  }

}

The Query URL is http://cmsnet.cms.net.nz/imageservice/persehtmlservice.svc/getimages?site=pukekohe&username=test

The application then starts another activity where the string list of image URLs that should be returned by the WCF call will be shown. Thanks

NoBones
  • 1
  • 2

0 Answers0