Lift
Lift

Reputation: 546

Sending a String result to a website

I'm rather new to Android Dev and I'm stuck at the very last part of my app. I've made a barcode scanning app (thanks Zxing) and would like to search the result on a website.

So for example if I wanted to search my result on www.trademe.co.nz how would I go about doing this?

So far I've gotten the String and opened the browser I just don't know how to import the text into the right textbox and search it.

The web part of my code.

private void openBrowser(String contents, String format) {
        Intent i = new Intent(Intent.ACTION_VIEW, 
                Uri.parse("http://www.trademe.co.nz"));
        startActivity(i);       

}

Sorry if I've done something wrong, this is my first post!

Thanks is advanced for any help :)

Upvotes: 1

Views: 166

Answers (2)

Wayne
Wayne

Reputation: 6449

Try this (and mark this as an answer if my answer solve your problem)

private void openBrowser(String contents, String format) {
String url = "http://www.trademe.co.nz/Browse/SearchResults.aspx?searchType=all&searchString=%s&rptpath=all&type=Search&generalSearch_keypresses=5&generalSearch_suggested=0";

try
    {
        your_keyword = URLEncoder.encode(your_keyword, "UTF-8")); //encode keyword
    }
    catch (UnsupportedEncodingException e)
    {          
        e.printStackTrace();
    }     

    url = String.format(url, your_keyword);
    Intent i = new Intent(Intent.ACTION_VIEW, 
            Uri.parse(url));
    startActivity(i);       

}

Upvotes: 1

Shalini
Shalini

Reputation: 1733

Use httpPost method to post your string to the url.

Check here

Also see a simple example here

Upvotes: 1

Related Questions