KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am developing an app which uses barcode to get the product information of items after scanning the barcode . I don't want the user to install ZXing barcode app separately so I embedded the ZXing code into my project. So I was able to obtain the barcode ID number . I want to get the product information like name, manufacturer, price etc using the bar code number using google search api for shopping. Here is the code I have used public class JSONExampleActivity extends Activity { TextView httpStuff; DefaultHttpClient client; JSONObject json; final static String URL = "https://www.googleapis.com/shopping/search"; String upc = "/v1/public/products?country=US&q=691464717759&restrictBy=gtin=691464717759"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); httpStuff = (TextView) findViewById(R.id.tvHttp); client = new DefaultHttpClient(); new Read().execute("items"); } public JSONObject products(String upc) throws ClientProtocolException, IOException, JSONException { StringBuilder url = new StringBuilder(URL); url.append(upc); HttpGet get = new HttpGet(url.toString()); HttpResponse r = client.execute(get); int status = r.getStatusLine().getStatusCode(); if (status == 200) { HttpEntity e = r.getEntity(); String data = EntityUtils.toString(e); JSONObject timeline = new JSONObject(data); return timeline; } else { Toast.makeText(JSONExampleActivity.this, "error", Toast.LENGTH_SHORT);
Tags (comma-separated)
Save Edits
Cancel