Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have Developing Application of Full Caller Id. In that dynamic screen call at the time of Incoming call / After Missed Call. Now this is work one time. When i received call. Than after it is not work or Not call any dynamic screen at the time Incoming call/ Missed call.
I have very confuse about my problem.

Java
Context c;
boolean cut, flag = true;
PhoneStateListener listener;
SharedPreferences prefs;
static boolean ring = false;
static boolean callReceived = false;

public MyPhoneStateListener(Context c) {
    // TODO Auto-generated constructor stub
    this.c = c;
}

@Override
public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);

    Log.d("main", "incoming call receiver.");
    PowerManager pm = (PowerManager) c
            .getSystemService(Context.POWER_SERVICE);
    boolean isScreenOn = pm.isScreenOn();

    switch (state) {
    case TelephonyManager.CALL_STATE_IDLE:
        Log.v("idle state", "CALL_STATE_IDLE");
        // CALL_STATE_IDLE;


        if (ring == true && callReceived == false && CheckMissCall.isReject==false) {

            Log.v("missed call", "Missed call from : " + incomingNumber);
            if(CheckMissCall.isShown)
            {
                c.stopService(new Intent(c, Unlock_hud.class));

            }

            flag = true;
            if (prefs.getBoolean("main_state", true))
            {
                Intent inter = new Intent(c, MissCall.class);
                inter.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                inter.putExtra("CellNumber", incomingNumber);
                c.startActivity(inter);
            }

        }       

        if(ring == true && callReceived == true && CheckMissCall.isReject == true)
        {
            Intent inter = new Intent(c, callLog.class);
            inter.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);          
            c.startActivity(inter); 
        }       
        break;


    case TelephonyManager.CALL_STATE_OFFHOOK:
        // CALL_STATE_OFFHOOK;
        callReceived = true;
        Log.v("call received", "CALL_STATE_OFFHOOK  " + incomingNumber);
        break;


    case TelephonyManager.CALL_STATE_RINGING:
        ring = true;
        // CALL_STATE_RINGING
        Log.v("call ringing", "CALL_STATE_RINGING  " + incomingNumber);
        Log.d("flags", "flags: " + flag);
        if (flag) {

            //cut = true;
            //flag = false;
            CheckMissCall call = new CheckMissCall(c);
            call.setName(incomingNumber);
            call.setNumber4Sms(incomingNumber);
            call.setContactPhoto();

            Log.d("main", "state ringing");
            prefs = PreferenceManager.getDefaultSharedPreferences(c);

            if (!prefs.getBoolean("main_state", false)) {

                return;
            }
        /*  if (!isScreenOn && CheckMissCall.isRunning) {

                return;
            }*/
            if (CheckMissCall.isRunning) {

                return;
            }
            else {
                Log.d("main", "EEEEEEEEEEEEEEEE:  Unlock hud");
                Intent in = new Intent(c, Unlock_hud.class);
                in.setFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
                c.startService(in);

                // c.stopService(new Intent(c, Unlock_hud.class));
            }
        }
        break;



    }



}
Posted
Comments
mathiazhagan01 1-Aug-14 9:53am    
Are you doing it in receiver or activity?
Member 10678436 2-Aug-14 3:02am    
i'm doing it in Receiver.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900