0
在我的Android應用程序中,我使用條形碼閱讀器獲取任何產品的UPC代碼。 但一旦我得到upc代碼我如何可以通過編程獲得細節。如何從upc獲取產品詳細信息?
我搜索互聯網上,有一件事我發現是「去upcdatabase網站,鍵入UPC號碼和詳細信息將顯示」但必須有一個API來獲取這些信息的權利。有人能幫我解決這個問題嗎?謝謝。
忽略下面的代碼:
package com.android.barcode;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class BarcodeActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IntentIntegrator.initiateScan(this);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case IntentIntegrator.REQUEST_CODE: {
if (resultCode != RESULT_CANCELED) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(
requestCode, resultCode, data);
if (scanResult != null) {
String upc = scanResult.getContents();
// put whatever you want to do with the code here
TextView tv = new TextView(this);
tv.setText(upc);
setContentView(tv);
}
}
break;
}
}
}
}
有你解決了這個問題,我也有新的Android和發現解決方案相同。 – jagdish