how to display dialog on top of screen when user get call in android?
<p>thanks i want to display caller information when user get call,for that i write the code from 
<a href="http://stackoverflow.com/questions/7121508/android-taking-complete-control-of-phone-is-it-possible-how/7121586#7121586">here</a></p>

<p>i test in real device,but when any one call me, the dialog wan not open why? if something wrong by please tell me 
i used the following code </p>

<pre><code>public class MyPhoneStateListener extends Service{

@Override
public IBinder onBind(Intent arg0) {
    return null;
}
Context context;
@Override
public void onCreate() {
    super.onCreate();
    context = this;
        StateListener phoneStateListener = new StateListener();
        TelephonyManager telephonymanager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
        telephonymanager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);


}

class StateListener extends PhoneStateListener{
    Dialog  dialog;
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
        super.onCallStateChanged(state, incomingNumber);
        switch(state){
            case TelephonyManager.CALL_STATE_RINGING:
                //Disconnect the call here...

                Intent intent = new Intent(context,PopUpOnGetingCallActivity.class);
                startActivity(intent);
                break;
            case TelephonyManager.CALL_STATE_OFFHOOK:
                //dialog.dismiss();
                break;
            case TelephonyManager.CALL_STATE_IDLE:
                break;
        }
    }
};

@Override
public void onDestroy() {

}
</code></pre>

<p>}</p>
