一、跳转到打电话界面
private String phoneNumber = "";
private static final int PERMISSIONS_REQUEST_CALL_PHONE = 1;
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.CALL_PHONE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.CALL_PHONE},
PERMISSIONS_REQUEST_CALL_PHONE);
} else {
callPhone();
}
private void callPhone() {
Uri uri = Uri.parse("tel:" + phoneNumber);
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
startActivity(intent);
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == PERMISSIONS_REQUEST_CALL_PHONE) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
callPhone();
} else {
// Permission Denied
ToastUtil.show("Permission Denied");
}
return;
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
二、跳转到发送短信界面
Uri uri = Uri.parse("smsto:" + phone);
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra("sms_body", “短信内容”);
startActivity(intent);
添加权限:
Manifest.permission.SEND_SMS
三、打开本地浏览器
Uri uri = Uri.parse("https://www.baidu.com");
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);