Android 拨打电话(跳转拨打及直接拨通)

跳转拨打页面:Intent(Intent.ACTION_VIEW, Uri.parse("tel:10086"))
直接拨通电话:Intent(Intent.ACTION_CALL, Uri.parse("tel:10086")) //需要动态授权<uses-permission android:name="android.permission.CALL_PHONE" />

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
CallPhonePromptDialogHelper.warnPrompt(AppBlogActivity.this, new CallPhonePromptDialogHelper.OnCallPhoneListener() {
@Override
public void onCallPhone() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
RxPermissionHelper.requestCallPhonePermissions(AppBlogActivity.this, new RxPermissionHelper.PermissionsCheckListener() {
@Override
public void onPermissionsGranted(int permissionType) {
NLog.i(Constants.TAG, "AppBlogActivity.onPermissionsGranted");
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:10086"));
if (checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
AppBlogActivity.this.startActivity(intent);
}

@Override
public void onPermissionsDenied(int permissionType) {
NLog.i(Constants.TAG, "AppBlogActivity.onPermissionsDenied");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:10086"));
AppBlogActivity.this.startActivity(intent);
}
});
} else {
// 拨号: 激活系统的拨号组件
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:10086"));
AppBlogActivity.this.startActivity(intent);
}
}
});

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :