我的代码是这样的:
public void onclickdial(View v) {
String str = "*#06#";
startActivity(new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+str)));
Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT).show(); }
但是有一个问题,拨号屏幕上只显示*符号:
最佳答案
String str = "*#06#";
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.fromParts("tel", str, ","));
Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT).show();
startActivity(callIntent);
或者:
String str = "*#06#";
startActivity(new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+ Uri.encode(str))));
Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT).show();
关于java - 单击按钮打开拨号盘,该字符串例如 String str = "*#06#"应该在拨号盘中打开。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44027339/