【问题标题】:click button to open dial pad, this string for example String str = "*#06#" should be open in dial pad.?单击按钮打开拨号盘,例如 String str = "*#06#" 这个字符串应该在拨号盘中打开。?
【发布时间】:2017-10-17 01:30:37
【问题描述】:

我的代码是这样的:

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(); }

但有一个问题,拨号屏幕上只显示*符号:

【问题讨论】:

    标签: java buttonclick


    【解决方案1】:
            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();
    

    【讨论】:

    • 非常感谢您
    猜你喜欢
    • 2023-03-26
    • 2014-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-07
    • 1970-01-01
    • 2021-08-29
    • 1970-01-01
    相关资源
    最近更新 更多