2016-09-18 189 views
-2

我想通過Android中的應用程序打電話,不會顯示顯示。這裏是我的代碼:Android意圖電話呼叫

Intent intent = new Intent(Intent.ACTION_CALL_BUTTON).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);   intent.setData(Uri.parse("tel:" + "+XXX"));   intent.putExtra("com.android.phone.extra.slot", 0); 
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) 
{  // TODO: Consider calling 
     // ActivityCompat#requestPermissions    
     // here to request the missing permissions, and then overriding     // public void onRequestPermissionsResult(int requestCode, String[] permissions,    //           int[] grantResults)    // to handle the case where the user grants the permission. See the documentation    // for ActivityCompat#requestPermissions for more details.    return;   } 
     getApplicationContext().startActivity(intent);  
} 

,並表示這個錯誤:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL_BUTTON dat=tel:xxxxxxxxxxxxxx flg=0x10000000 (has extras) } 

我該怎麼辦?

回答

0

爲什麼不這樣做? (目標SDK = 22)

String phone = [phone number];  

Intent localIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + phone)); 

[context].startActivity(localIntent);