Android : Ringing call state is not work after Received 1st call android

on Monday, August 4, 2014


i'have confuse about my code. I'm open activity it the time of Incoming Call/ Missed Call. But its open only 1st time till the received call. after receiving 1st call Not work Ringing state.



switch (state) {
case TelephonyManager.CALL_STATE_IDLE:

Log.v("idle state", "CALL_STATE_IDLE");
// CALL_STATE_IDLE;


if (ring == true && callReceived == false && CheckMissCall.isRunning== 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;


Now what i have to do ..??


0 comments:

Post a Comment