我正在使用以下代码从我的 android 代码调用电话。但它似乎不起作用。所有这些代码所做的只是在调用应用程序中显示电话号码,但它不打电话。
Uri call=Uri.parse("tel:9008765750");//that's an example phone number
Intent ii= new Intent(Intent.ACTION_VIEW,call);
startActivity(ii);
最佳答案
改变
Intent ii= new Intent(Intent.ACTION_VIEW,call);
到
Intent ii= new Intent(Intent.ACTION_CALL,call);
并添加权限<uses-permission android:name="android.permission.CALL_PHONE" />
Intent.ACTION_VIEW
用于Display the data to the user.
所以当你使用 tel:
与 Intent.ACTION_VIEW
它只会显示数字。
Intent.ACTION_CALL
用于Perform a call to someone specified by the data.
关于android - 为什么我不能使用 Uri 类进行调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24803899/