2012-03-20 3 views
0

У меня есть приложение, вызывающее вызов по конкретному номеру телефона, если число не ответит, что приложение совершает какое-либо действие, мой вопрос: как я могу узнать, есть ли ответ или нет? ?!Как проверить, есть ли ответ

вот мой код:

PhoneCallListener phoneListener = new PhoneCallListener();  
TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); 

    telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE); 



    Button emr = (Button) findViewById (R.id.emergButton); 
    emr.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      Model m = new Model() ; 
      num=m.getAdminPhone(); 
      String Numb = "tel:"+num; 
       Intent callIntent = new Intent(Intent.ACTION_CALL); 
       callIntent.setData(Uri.parse(Numb)); 
       startActivity(callIntent); 

      if() // here i want to making a check... 
      {answer = true;} 



     } 
    }); 

ответ

0

This answer должно помочь.

TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 
tm.listen(mPhoneListener, PhoneStateListener.LISTEN_CALL_STATE); 

private PhoneStateListener mPhoneListener = new PhoneStateListener() { 

    public void onCallStateChanged(int state, String incomingNumber) { 
     try { 
      if (state == TelephonyManager.CALL_STATE_OFFHOOK){ 
       // Call wasn't answered 
      } 
     } catch (RemoteException e) {} 
    } 
}; 
0

Кажется, нет способа получить результат от дозвона. This topic может помочь вам это осознать. Таким образом, использование подхода @Cameron выглядит лучше.

Не смешно ли заполнять ответ, чтобы принять другой ответ? ;)