【发布时间】:2020-02-23 08:13:38
【问题描述】:
我使用此代码显示号码,并在按下它进行拨号时使用它。它适用于 Android Pie 之前的 android 版本。
final Button but= findViewById(R.id.buttond);
but.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String PhNumber = "6998474783";////example number
final CharSequence[] phones = PhNumber.split(" - ");
AlertDialog.Builder builder = new AlertDialog.Builder(CTX);
builder.setTitle("Επιλογή Τηλεφώνου");
builder.setItems(phones, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
// Do something with the selection
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phones[item].toString()));
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return; }
startActivity(intent);
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
要使用 Pie 及更高版本,我必须进行哪些更改? 它显示了电话号码,但当我按下它时没有任何反应
【问题讨论】:
标签: android-9.0-pie android-phone-call telecom-manager