铃声管理器不停止铃声android

时间:2014-08-25 07:46:07

标签: java android audio notifications ringtone

我有两个类incomingCallRing.java和IncomingCallSlider.java 一个类显示UI,第二个类定义函数。 我遇到的问题是,当我点击拒绝呼叫按钮时,来电的音乐不会停止。这是两个类的代码。

incomingCallSlider.java

private void RejectCall()
{
    m_objBtnRejectCall = (Button) m_objActiveActivity.findViewById(R.id.RejectCallButton);

    m_objBtnRejectCall.setOnClickListener(new OnClickListener()
    {
        public void onClick(View arg0) 
        {
            //Log.e("Reject Call", m_sIncomingCallId);

            VaxPhone.m_objVaxVoIP.RejectCall(m_sIncomingCallId);
            HideSlider();

            if(IncommingCall != null)
                IncommingCall.cancel(0);
        }       });   }

IncomingCallRing.java

public static IncommingCallRing m_objIncommingCallRing;

        Ringtone m_objRingtone;

        Activity m_objActiveActivity;


    public IncommingCallRing() 
    {
        m_objIncommingCallRing = this;
    }

    public void SetActiveActivity(Activity ReferenceActivity)
    {
        m_objActiveActivity = ReferenceActivity;
    }

    private void StartRingtone()
    {
        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        m_objRingtone = RingtoneManager.getRingtone(m_objActiveActivity.getApplicationContext(), notification);
        m_objRingtone.play();
    }

    private void StopRingtone()
    {



        if(m_objRingtone == null)
            return;

        if(m_objRingtone.isPlaying())
            m_objRingtone.stop();

    }

0 个答案:

没有答案