android从broadcastreceiver发送action_call

时间:2013-06-12 07:04:29

标签: android broadcastreceiver call forward

我希望在收到短信后转发所有电话,所以我必须使用broadcastreceiver来收听短信,这是我的代码:

public class SMSListiner extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equalsIgnoreCase("android.provider.Telephony.SMS_RECEIVED")) {
        Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode("*21*02164371348#")));
        callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(callIntent);
    }}

这是显而易见的

`

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.arash.SMSListiner">
    <uses-sdk android:minSdkVersion="10"/>
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Main">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"></action>
                <action android:name="android.intent.category.LAUNCHER"></action>
            </intent-filter>
        </activity>
        <receiver android:name=".SMSListiner">
            <intent-filter android:priority="999">
                <action android:name="android.provider.Telephony.SMS_RECEIVED"></action>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
            </intent-filter>
        </receiver>
    </application>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
    <uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
    <uses-permission android:name="android.permission.READ_SMS"></uses-permission>
    <uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
    <uses-permission android:name="android.permission.BROADCAST_SMS"></uses-permission>
    <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />

</manifest>

`

发送了电话,但我有一个错误: “呼叫转移,连接问题或无效的MMI代码”

但是当我尝试使用此代码在活动中发送action_call时,我没有问题,并且它正常工作, 任何想法?

0 个答案:

没有答案