2

我有一个可以调用“帮助呼叫”的应用程序。我希望当某人接受呼叫时呼叫在后台运行。那么有没有办法减少电话通话并同时返回应用程序?

4

1 回答 1

2

你可以试试这样的

private class CallStateListener extends PhoneStateListener {

    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
        switch (state) {
            case TelephonyManager.CALL_STATE_RINGING: {
                break;
            }
            case TelephonyManager.CALL_STATE_OFFHOOK: {
                try {
                    //THIS WILL SIMULATE A HOME BUTTON PRESS
                    //Effectively Minimizing the In Call Screen
                    Intent startMain = new Intent(Intent.ACTION_MAIN);
                    startMain.addCategory(Intent.CATEGORY_HOME);
                    startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    activity.startActivity(startMain);

                    //Now that you are home, and your In Call Screen is minimized
                    //move back to your application
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            }
        }
    }
}
于 2014-01-09T22:33:08.960 回答