gpt4 book ai didi

android: 调用电话

转载 作者:行者123 更新时间:2023-11-29 15:29:28 25 4
gpt4 key购买 nike

我在安卓系统工作。

我想调用显示在文本框中的号码。这是我在 xml 文件中的代码:-

 <TextView android:id="@+id/textView_event_place_contactNo"

android:text="Contact No"

android:layout_height="wrap_content"

android:layout_width="wrap_content"

android:textColor="#000000"

android:textSize="10dp"

android:phoneNumber="true" android:autoLink="phone"/>

这是我的代码:-

      textView_contactNo.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Intent callIntent = new Intent(Intent.ACTION_CALL);

callIntent.setData(Uri.parse("tel:9783506635"));

startActivity(callIntent);

}

});

以上代码运行正常。但问题是,每当我点击联系号码时,通话窗口就会打开,即使我不想调用该号码并按下后退按钮,我的通话也会接通。

所以请告诉我我应该怎么做,这样当我按下后退按钮时,调用应该不会接通。

最佳答案

将您的 Intent 类型更改为 Intent.ACTION_DIAL

Intent callIntent = new Intent(Intent.ACTION_DIAL);

使用此 Intent 类型,您可以选择调用或不调用该号码。

关于android: 调用电话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8385112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com