我想扫描条形码ID并将其发送到Google搜索引擎,但我遇到了问题。
当我扫描时,它将打开此URL而不获取ID:
https://www.google.com.pk/search?hl=en&q=scanContent
+
我想这样:
https://www.google.com.pk/search?hl=en&q=12345
< - (条形码ID)
我该怎么做?
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (scanningResult != null) {
if (scanningResult.getContents() != null) {
scanContent = scanningResult.getContents().toString();
scanFormat = scanningResult.getFormatName().toString();
}
Toast.makeText(this, scanContent + " type:" + scanFormat, Toast.LENGTH_SHORT).show();
textView.setText(scanContent + " type:" + scanFormat);
Intent browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com.pk/search?hl=en&q=scanContent + "));
startActivity(browserIntent);
} else {
Toast.makeText(this, "Nothing scanned", Toast.LENGTH_SHORT).show();
}
}
}
答案 0 :(得分:0)
不要把
Intent browserIntent = newIntent(Intent.ACTION_VIEW,Uri.parse(" https://www.google.com.pk/search?hl=en&q=scanContent +"));
startActivity(browserIntent);