Java 当状态呼叫响起时执行命令
我有一个小应用程序要在Android上制作 所以我有几个按钮,每个按钮首先调用一个特定的中间号码。 在第一次通话后,我必须等待约15秒,应用程序必须拨打真实号码 例如,我点击一个名为“toto”的按钮,其电话号码为001,因此应用程序首先拨打中间号码,例如000,然后会有声音说他必须等待几秒钟才能到达toto 现在我有这个:Java 当状态呼叫响起时执行命令,java,android,Java,Android,我有一个小应用程序要在Android上制作 所以我有几个按钮,每个按钮首先调用一个特定的中间号码。 在第一次通话后,我必须等待约15秒,应用程序必须拨打真实号码 例如,我点击一个名为“toto”的按钮,其电话号码为001,因此应用程序首先拨打中间号码,例如000,然后会有声音说他必须等待几秒钟才能到达toto 现在我有这个: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInsta
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TelephonyManager telephoneM = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
PhoneStateListener listner = new PhoneStateListener() {
public void onCallStateChanged(int state, String incomingnumber) {
String etat = "N/A";
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
etat = "pas de reponse";
Toast.makeText(MainActivity.this, "" + etat,
Toast.LENGTH_SHORT).show();
break;
case TelephonyManager.CALL_STATE_RINGING:
etat = "sonne";
Toast.makeText(MainActivity.this, "" + etat,
Toast.LENGTH_SHORT).show();
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
etat = "en ligne";
Toast.makeText(MainActivity.this, "" + etat,
Toast.LENGTH_SHORT).show();
break;
}
}
};
telephoneM.listen(listner, PhoneStateListener.LISTEN_CALL_STATE);
Btoto = (Button) findViewById(R.id.num1);
Btoto.setOnClickListener(this);
public void onClick(View v) {
switch (v.getId()) {
case R.id.num1:
Intent localIntent = new Intent("android.intent.action.CALL");
localIntent.setData(Uri.parse("tel:0153204255")); // the intermediate number
startActivity(localIntent);
//here I have to make a delay after the first ringing
// And here i have to make the real call to toto
break;
有人能给我一些建议吗
谢谢你这个问题的相似之处张贴在这里,谢谢你的帮助,但这并不是我所期望的。。。我想让我的应用程序拨打一个号码,几秒钟后再拨打另一个号码。。。有人能帮忙吗?