我正在构建一个应用程序,它应该允许您扫描 QR 码(或条形码),然后调用条形码/QR 码上的数字。我猜您无法启动处理来自另一个活动中的调用的活动,因为我收到以下错误:
没有找到处理 Intent 的 Activity { act=android.intent.action.CALL dat=tel:xxx=xxx=xxxx }
这是我的代码
public void scanNow(View view) {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}
@SuppressWarnings("deprecation")
public void onActivityResult(int requestCode, int resultCode, Intent intent){
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
try
{
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(contents));
startActivity(callIntent);
}
catch(Exception e)
{
messageBox("doStuff", e.getMessage());
}
// Handle successful scan
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}