安卓:重定向呼出电话 [英] Android: Redirect outgoing calls

查看:300
本文介绍了安卓:重定向呼出电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的重定向拨出电话到不同的电话号码的Andr​​oid设备上。所以,我用一个BroadcastReceiver听为NEW_OUTGOING_CALL意图,在他的onReceive()方法,我用的是setResultData()方法来更改电话号码。

这样的:

 公共无效的onReceive(背景为arg0,意图ARG1){

    setResultData(351978923221);

}
 

在模拟器中一切顺利,但是在我的实际设备(一个蹩脚的中兴X850采用Android 2.1我相信)它没有如果主叫意图源于一个活动至极的是同一个应用程序的一部分。出现拨号屏幕后,手机结束呼叫。

任何想法在那里,为什么出现这种情况?

注意:我知道我的问题是基本相同之一,但我还是选择了再次要求它无论如何要提供什么不顺心的其他详细信息。


清单文件

这是节选...

 <接收器安卓名=机器人OutgoingCallDetection。:出口=真正的>
        <意向滤光器>
            <作用机器人:名称=android.intent.action.NEW_OUTGOING_CALL
                    机器人:优先=9999/>
        &所述; /意图滤光器>
    < /接收器>

< /用途>

<使用-权限的Andr​​oid:名称=android.permission.CALL_PHONE/>
<使用-权限的Andr​​oid:名称=android.permission.PROCESS_OUTGOING_CALLS/>
 

解决方案

我切已拨电话和重拨新的呼叫。它完美地工作在设备上。

这是在code部分:

  setResultData(空);
开放的我们的uri = Uri.fromParts(电话,!要拨打的号码!,NULL);
意图newIntent =新的意图(Intent.ACTION_CALL,URI);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);
 

希望这有助于。

I'm trying to redirect outgoing calls to a different phone number on an Android device. So, I use a BroadcastReceiver "listening" for the NEW_OUTGOING_CALL intent, on his onReceive() method I use the setResultData() method to change the phone number.

Like this:

public void onReceive(Context arg0, Intent arg1) {

    setResultData("351978923221");

}

In the emulator all goes well, but on my real device (a crappy ZTE X850 with Android 2.1 I believe) it doesn't if the calling Intent originates in an Activity wich is part of the same application. After the dialing screen appears, the phone terminates the call.

Any thoughts out there on why this happens?

Note: I know my question is basically the same as this one but I chose to ask it again anyway to provide additional details about what goes wrong.


Manifest File

An excerpt...

    <receiver android:name=".OutgoingCallDetection" android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.NEW_OUTGOING_CALL"
                    android:priority="9999" />
        </intent-filter>
    </receiver>

</application>

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

解决方案

I cut the dialed call and redialed the new call. It worked perfectly on the device.

This is the code part:

setResultData(null);
Uri uri = Uri.fromParts("tel", "!Number to be dialed!", null);
Intent newIntent = new Intent(Intent.ACTION_CALL, uri);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);

Hope this helps.

这篇关于安卓:重定向呼出电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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