0

I want custom calling screen I have achieved that but problem is that my screen is not going back when call cuts.i(..) want to terminate screen when call cuts. My code is:

public class receiver_Call extends BroadcastReceiver {
    public void onReceive(final Context context, Intent intent) {

        Thread pageTimer = new Thread(){
            public void run(){
                try{

                    sleep(1000);

                } catch (InterruptedException e){
                    e.printStackTrace();
                } finally {
                    //Toast.makeText(context," text", 5).show();
                    Intent i = new Intent();
                    i.setClass(context, My_call_receiver.class);
                    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                    context.startActivity(i);

                }
            }
        };
        pageTimer.start();
    }
}
Vladimir
  • 9,913
  • 4
  • 26
  • 37
Jinal Patel
  • 699
  • 5
  • 15

1 Answers1

0

Have you tried a listener for when the call ends:

EndCallListener callListener = new EndCallListener();
TelephonyManager mTM = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
mTM.listen(callListener, PhoneStateListener.LISTEN_CALL_STATE);

And in your Listener:

private class EndCallListener extends PhoneStateListener {
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {

        if(TelephonyManager.CALL_STATE_RINGING == state) {}
        if(TelephonyManager.CALL_STATE_OFFHOOK == state) {}
        if(TelephonyManager.CALL_STATE_IDLE == state) {}

    }
}

EndCallListener is your class which extends PhoneStateListener (which is defined above)

Pararth
  • 8,114
  • 4
  • 34
  • 51
  • what is Endcall listner in this? – Jinal Patel Jan 29 '14 at 09:12
  • You can use PhoneStateListener http://developer.android.com/reference/android/telephony/PhoneStateListener.html http://stackoverflow.com/questions/13395633/add-phonestatelistener – Pararth Jan 29 '14 at 09:28