试试这样。。
Toast.Length_LONG gives toast for only 3.5 seconds..
所以..像这样创建一个 3.5 秒的倒数计时器..在你的活动的 onCreate
String state= bundle.getString(TelephonyManager.EXTRA_STATE);
MyCount counter;
counter=new MyCount(3500,1000);
counter.start();
MyCount 类..
public class MyCount extends CountDownTimer{
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
if (state.equalsIgnoreCase(TelephonyManager.EXTRA_INCOMING_NUMBER){
Toast toast= new Toast(youractivity.this);
toast.setGravity(Gravity.TOP,0,0);
toast.setDuration(Toast.Length_LONG);
toast.makeText(..).show();
toast.show();
counter= new MyCount(3500,1000);
counter.start();
}
}
@Override
public void onTick(long millisUntilFinished) {
}
}
}
这会持续显示敬酒,直到您接听电话..或您的来电因超时而结束..