i have develop code of call back on Missed Call number. in My code i confuse at which position i put intent on new activity. i also open activity at the time of Incoming Call. but At the time of Miscall i confuse. So how can i open Activity after Missed call .
Code
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();
if (state == TelephonyManager.CALL_STATE_RINGING) {
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;
}
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);
}
}
}
else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
Log.d("main", "offhook");
}
else {
if (cut && CheckMissCall.isShown) {
Log.d("main", "Cutted");
c.stopService(new Intent(c, Unlock_hud.class));
flag = true;
}
}
}
}