INTENT.ACTION_CALL背景 [英] INTENT.ACTION_CALL in background

查看:180
本文介绍了INTENT.ACTION_CALL背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在后台调用我的应用程序,所以当用户点击一个按钮,就应该开始打电话的背景下,用户会知道他是打电话,但他不会看到拨号器,他将看到应用程序,重现声音,而打来的。

I need to call in background in my app, so when the user click a button, it should start calling in the background, the user will know that he is calling, but he wont see the Dialer, he will see the app, to reproduce sounds while calling.

所以基本上我想要的是拨打电话,而不活动的退出

So basically what i want is make a call without exit of the activity

我trye​​d一个服务,但它不工作

I tryed with a service but it doesnt work

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

对不起我的英语

推荐答案

code背后:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    call();
}

private void call() {
    try {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:123456789"));
        startActivity(callIntent);
    } catch (ActivityNotFoundException e) {
        Log.e("sample call in android", "Call failed", e);
    }
}

的Manifest.xml 结果
添加..

Manifest.xml
Add..

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

或者

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

编辑:
好吧, tasomaniac 做哪些OP也希望现有的当前活动的好点。

Well,tasomaniac made a good point about existing current activity which OP also wants.

所以我想主要的是拨打电话的无活性的出口

So basically what i want is make a call without exit of the activity.

但是,这是不可能做到在电话接口的调用状态在任何可能的android.One很好的解决办法是 PhoneStateListener 来看看当通话结束,然后恢复你的目前activity.Some很好的解决方案描述。

But it is impossible to do anything during call states of telephony interface in android.One possible good solution would be PhoneStateListener to see when the call is ended and then resume your current activity.Some very good solutions are described..

  • How to make a phone call in android and come back to my activity when the call is done?

这篇关于INTENT.ACTION_CALL背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆