无法从活动中发起呼叫

时间:2013-09-18 14:03:55

标签: android android-intent zxing

我正在构建一个应用程序,允许您扫描QR码(或条形码),然后在条形码/ QR码上调用nubmer。我猜你不能启动一个处理来自另一个活动中的调用的活动,因为我收到以下错误:

  

找不到活动来处理Intent {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
            }
        }

0 个答案:

没有答案