android - INTENT.ACTION_CALL 在后台

标签 android android-intent android-service

我需要在我的应用程序中在后台调用,因此当用户单击按钮时,它应该开始在后台调用,用户会知道他正在调用,但他不会看到拨号器,他会看到应用程序,在通话时再现声音。

所以基本上我想要的是在不退出 Activity 的情况下调用电话

我尝试了一项服务,但它不起作用

 Intent callIntent = new Intent(Intent.ACTION_CALL);
 callIntent.setData(Uri.parse("tel:123456789"));
 startService (callIntent);

对不起我的英语

最佳答案

试试这个:

Intent callIntent = new Intent(Intent.ACTION_CALL);
 callIntent.setData(Uri.parse("tel:123456789"));
 startActivity(callIntent);

*注意 startActivity(callIntent),而不是 startService(callIntent);

您还可以尝试使用 ACTION_DIAL,而不是 ACTION_CALL。您还需要此权限,但请将其放在 AndroidManifest 中的 Application 标记之前:

<uses-permission android:name="android.permission.CALL_PHONE" />

关于android - INTENT.ACTION_CALL 在后台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17676221/

相关文章:

java - 如何从android中的扫描结果中过滤特定的SSID?

android - ListFragment 中的项目不会显示在使用自定义数组适配器的 Listview 中

Android:安装 apk Intent (monodroid)

android 列出 sd 卡上的音频并播放

android - Kotlin : On camera move end

android - 我如何在 AsyncTask 中从 onPostExecute 发回数据?

java - 基本 Activity 开始

android - 永久收听剪贴板更改

android - 在不使用 SYSTEM_ALERT_WINDOW 的情况下使用服务中的正负按钮显示警报

android - 从 IntentService 调用 AsyncTask 的问题