Android以编程方式关闭拨号器

时间:2014-01-15 17:02:04

标签: android phone-call

我正在启动来自某项活动的电话,并希望在7秒后自动关闭拨号程序(并结束通话)。

此代码不起作用:

private static final int REQUEST_CALL = 135;
private long nCallShouldEndAfterMs = 7 * 1000;

private void callNumber()
{
    Intent callIntent = new Intent(Intent.ACTION_CALL);
    callIntent.setData(Uri.parse("tel:" + sMyNum));
    startActivityForResult(callIntent, REQUEST_CALL);

    scheduleClosingDialer();
}


private void scheduleClosingDialer()
{
    handler.postDelayed(new Runnable()
    {           
        @Override
        public void run()
        {
            try
            {
                Log.d(TAG, "closing dialer");
                finishActivity(REQUEST_CALL);
            }
            catch(Exception e)
            {
                Log.w(TAG, "Dialer already closed");
            }               
        }
    }, nCallShouldEndAfterMs);
}

0 个答案:

没有答案