2012-11-09 17 views

Trả lời

15
Intent intent = new Intent(Intent.ACTION_DIAL); 
startActivity(intent); 
+0

thanx làm việc của nó :) –

+0

Không có vấn đề (: vui mừng khi giúp – MrYanDao

3
Intent intent = new Intent(Intent.ACTION_CALL_BUTTON); 
      startActivity(intent); 

nó sẽ hiển thị Quay số cửa sổ séc here để biết thông tin

12
Intent intent = new Intent(Intent.ACTION_DIAL); 
intent.setData(Uri.parse("tel:9999999999")); 
startActivity(intent); 

Đối với điều này chúng ta không cần thêm bất kỳ sự cho phép trong AndroidManifest.xml

+0

Đối ACTION_DIAL, chúng ta không cần CALL_PHONE Permission. Nó chỉ cần cho ACTION_CALL – Mani

0
Intent callIntent = new Intent(Intent.ACTION_DIAL); 
callIntent.setData(Uri.parse("tel:" + phoneNumber)); 
if (ActivityCompat.checkSelfPermission(getActivity(), 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; 
      } 
startActivity(callIntent); 

Ngoài ra, bạn nên đăng ký màn hình quay số tùy chỉnh như sau manifest:

<application 
android:icon="@drawable/ic_launcher" 
android:label="@string/app_name" > 
<activity 
    android:name=".MyDialerApplication" 
    android:label="@string/app_name" > 

    <intent-filter android:priority="100" > 
     <action android:name="android.intent.action.MAIN" /> 
     <action android:name="android.intent.action.DIAL" /> 
     <action android:name="android.intent.action.CALL_PRIVILEGED" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <data android:scheme="tel" /> 

    </intent-filter> 
</activity>