Bonjour,
Comment puis-je savoir si un numéro est occupé?! L'idée serait d'appeler automatiquement un numéro après 10min quand ce serait le cas.
Avec la class EndCallListener j'arrive seulement à savoir si quelqu'un m'appel.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 @Override public void onClick(View view) { EndCallListener callListener = new EndCallListener(); TelephonyManager mTM = (TelephonyManager) (MainActivity.this).getSystemService(Context.TELEPHONY_SERVICE); Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + <numero_de_telephone_a_appeler>)); startActivity(callIntent); mTM.listen(callListener, PhoneStateListener.LISTEN_CALL_STATE); }
Merci d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 public class EndCallListener extends PhoneStateListener { @Override public void onCallStateChanged(int state, String incomingNumber) { switch(state) { case TelephonyManager.CALL_STATE_RINGING: Log.i("APPEL", "MON TELEPHONE SONNE, number: " + incomingNumber); case TelephonyManager.CALL_STATE_OFFHOOK: Log.i("APPEL", "OFFHOOK"); case TelephonyManager.CALL_STATE_IDLE: Log.i("APPEL", "IDLE"); } } }
Partager