INTENT.ACTION_CALL背景背景、INTENT、ACTION_CALL

由网友(孤独的造梦者)分享简介:我需要在后台调用我的应用程序,所以当用户点击一个按钮,就应该开始打电话的背景下,用户会知道他是打电话,但他不会看到拨号器,他将看到应用程序,重现声音,而打来的。I need to call in background in my app, so when the user click a button, it sho...

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

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要在Android的一个电话,回来我的活动,在通话呢? How to make a phone call in android and come back to my activity when the call is done?
阅读全文

相关推荐

最新文章