I am developing an app which will show the service prvider (like Vodaphone etc) information , of incoming call.
I accommplished it using the toast. with following code
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
PhoneStateListener callStateListener = new PhoneStateListener() {
public void onCallStateChanged(int state, String incomingNumber)
{
// TODO React to incoming call.
if(state==TelephonyManager.CALL_STATE_RINGING)
{
Toast.makeText(getApplicationContext(),finder.find(incomingNumber), Toast.LENGTH_LONG).show();
}
}
};
telephonyManager.listen(callStateListener,PhoneStateListener.LISTEN_CALL_STATE);
the problem is Toast is visible for very little time. I want to make it visible till the user does not receive the call(i.e. till the phone is ringing, once recievd toast should disapper).
what should I do.
Can I use some other control like dialogbox etc.
thanks
run the toast in handler thread like following:
onclick of call button try the following:
and add this method in your class:
and cancel your toast onclick of end button or once the user picks the call:
otherwise use as like your function: