android呼叫转移代码,动态Android呼叫转移

我正在开发移动APP,我需要根据联系人组将呼入转移到不同的号码。我将我的联系人分组,每个组都有不同的呼叫转移号码。当我收到来电时,我应该转发它的群组。动态Android呼叫转移

我PhoneStateListener在Call_State_Ringing写了这个代码:

package com.example.user2.callforwardnew;

import android.app.Activity;

import android.content.Context;

import android.content.Intent;

import android.net.Uri;

import android.os.Bundle;

import android.telephony.PhoneStateListener;

import android.telephony.TelephonyManager;

import android.util.Log;

import android.widget.Toast;

public class CallActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

TelephonyManager telephonyManager =

(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);

PhoneStateListener callStateListener = new PhoneStateListener() {

public void onCallStateChanged(int state, String incomingNumber){

if(state==TelephonyManager.CALL_STATE_RINGING){

String url = "tel:" + "**21*" + "XXXXX" + Uri.encode("#");

Intent intent1 = (new Intent(Intent.ACTION_CALL, Uri.parse(url)));

intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(intent1);

}

if(state==TelephonyManager.CALL_STATE_OFFHOOK){

Toast.makeText(getApplicationContext(),"Phone is Currently in A call",

Toast.LENGTH_LONG).show();

}

if(state==TelephonyManager.CALL_STATE_IDLE){

Toast.makeText(getApplicationContext(),"phone is neither ringing nor in a call",

Toast.LENGTH_LONG).show();

}

}

};

telephonyManager.listen(callStateListener,PhoneStateListener.LISTEN_CALL_STATE);

}

}

的问题是:当第一个电话来了也不会转发它只是在电话呼叫转移登记XXXX号。那么第二个电话会在正确的时间转发。 的问题: 我如何转发来电根据来电显示

+0

_第一次来电时,它不会被转发,它只是在电话转接中注册xxxx号码。您能解释一下吗,这个不清楚 –

+0

第一:电话转接设置被禁用。 打开:设置>我的设备>呼叫>附加设置>呼叫转移>语音呼叫。 然后第一个电话会来,手机将测距,并没有呼叫转移。但是第一次来电后,电话转接设置将被启用,并且xxxx号码将被登记在电话呼叫转接设置中。 第二次收入电话会正确转发给xxxx。 –

+0

嗯,我猜你的意图是启用设置(不知道这个系统)。所以我认为这是逻辑。收到的电话已经收到,因此转发已经晚了。你可以尝试手动。 (不知道你可以改变设置将接到一个电话,但它probalby将不会被转发,如果它已经振铃) –

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值