I am working on an application in which I have to override the INCOMING CALL SCREEN.
When device receives a call, I have to show a popup of my application. I have done a detailed research about this task. CALL POPOUT is an application which is using the same functionality, but I am not getting the source code.
Currently I am having few modules by which we can get the action of INCOMING CALL.
public class MyPhonestateListner extends PhoneStateListener {
Context context;
List<String> blockedNumberList = new ArrayList<String>();
BlockDataSource datasourceobj;
public MyPhonestateListner(Context context) {
super();
this.context = context;
}
@Override
public void onCallStateChanged(int state, String callingNumber) {
super.onCallStateChanged(state, callingNumber);
callingNumber = callingNumber.replace(" ", "");
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
// handle out going call
// if(blockedNumberList.contains(callingNumber))
endCallIfBlocked(callingNumber);
break;
case TelephonyManager.CALL_STATE_RINGING:
// handle in coming call
new Handler().postDelayed(new Runnable() {
public void run() {
Intent intentPhoneCall = new Intent("android.intent.action.CALL");
intentPhoneCall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intentPhoneCall);
}
}, 10);
// if(blockedNumberList.contains(callingNumber))
//endCallIfBlocked(callingNumber);
// ActivityManagerNative.getDefault().moveTaskToBack(i);
//android.app.ActivityManager.RunningTaskInfo runningtaskinfo = TaskUtil.getPresentTaskInfo(this);
break;
default:
break;
}
}
}
MY reciever
public class BlockReciever extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
System.out.println("I am reciever");
TelephonyManager telephony = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
MyPhonestateListner listener = new MyPhonestateListner(context);
telephony.listen(listener, PhoneStateListener.LISTEN_CALL_STATE);
}
}
With the help of above code, I am getting the MAP screen of my Application on TOP of CALL SCREEN, but JUST FOR FEW MICRO SECONDS and then the INCOMING CALL SCREEN comes on the top. I HAVE TO HIDE THE CALL SCREEN when device receives any call and need to show the screen of my application.
Please suggest.