如何在我的 android 应用程序中调用通配符号码?
How can i make a call on wildcard numbers in my android application?
我正在申请,用户通过摄像头扫描卡号(14 位)号码,然后拨打电话。该呼叫需要在号码末尾使用通配符“#”,但我的应用程序不添加该字符。我该怎么办?
我正在使用这个
String cardNumber = textValue.getText().toString().trim();
int permissionCheck = ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PHONE);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.CALL_PHONE}, Integer.parseInt("123"));
}
else {
startActivity(new Intent(Intent.ACTION_DIAL).setData(Uri.parse("tel:*123*"+cardNumber+"#")));
}
您可以使用此代码解决您的问题:
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:"+ Uri.encode("*123#")));
startActivity(callIntent);
或
在运行时增加价值
Intent callIntent = new Intent(Intent.ACTION_DIAL);
String cardnm = "8585"; // cardname value......
callIntent.setData(Uri.parse("tel:" + Uri.encode("*123*" + cardnm + "#")));
startActivity(callIntent);
我正在申请,用户通过摄像头扫描卡号(14 位)号码,然后拨打电话。该呼叫需要在号码末尾使用通配符“#”,但我的应用程序不添加该字符。我该怎么办?
我正在使用这个
String cardNumber = textValue.getText().toString().trim();
int permissionCheck = ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PHONE);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.CALL_PHONE}, Integer.parseInt("123"));
}
else {
startActivity(new Intent(Intent.ACTION_DIAL).setData(Uri.parse("tel:*123*"+cardNumber+"#")));
}
您可以使用此代码解决您的问题:
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:"+ Uri.encode("*123#")));
startActivity(callIntent);
或
在运行时增加价值
Intent callIntent = new Intent(Intent.ACTION_DIAL);
String cardnm = "8585"; // cardname value......
callIntent.setData(Uri.parse("tel:" + Uri.encode("*123*" + cardnm + "#")));
startActivity(callIntent);