从自定义传出屏幕拨打电话

时间:2016-01-04 08:44:51

标签: android call

我想更换外出屏幕并通过该自定义屏幕拨打电话。我成功带来自定义屏幕,但我无法拨打电话。如果我使用ACTION.CALL,则调用默认传出屏幕。

public class OutgoingCallBroadcastReciver extends BroadcastReceiver {
    Context c;
    public OutgoingCallBroadcastReciver() {

    }

    @Override
    public void onReceive(final Context context, final Intent intent) {
        final String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        c=context;
        setResultData(null);
        setResultData(number);
        callActionHandler.postDelayed(runRingingActivity, 1000);

    }

    Handler callActionHandler = new Handler();
    Runnable runRingingActivity = new Runnable(){

        @Override
        public void run()
        {
            Intent intentPhoneCall = new Intent(c, OutgoingScreen.class);
            intentPhoneCall.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intentPhoneCall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            c.startActivity(intentPhoneCall);
        }

    };
}

1 个答案:

答案 0 :(得分:0)

对于传出呼叫,我自定义解决方法并在清单中创建传出接收方的自定义权限。

我在使用处理程序延迟后调用了该活动。

希望我会为你工作。

请检查以下代码。

@Override
public void onReceive(Context context, Intent intent) 
{
    mcontext = context;
    setResultData(null);
    dialphonenumber = getResultData();
    if dialphonenumber == null)
    {
        dialphonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    }
    setResultData(dialphonenumber);
    callActionHandler.postDelayed(runRingingActivity, 1000);
}


Handler callActionHandler = new Handler();
Runnable runRingingActivity = new Runnable() 
{
    @Override
    public void run() 
    {

        Intent intentPhoneCall = new Intent(mcontext, OutgoingCallActivity.class);
        intentPhoneCall.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intentPhoneCall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mcontext.startActivity(intentPhoneCall);
    }
};

希望它对你有用。

如果您有任何问题,请告诉我。