I'm using a Broadcast Receiver to intercept a phone call. I want to overlay the default incoming call screen with the name of the caller. I have an application with a database that maintains phone numbers separately from my contacts.
I am intercepting the call just fine, but when I display the popup, it doesn't overlay on top of the default incoming call screen. The incoming call screen opens up, then is replaced by my application (it goes to the last activity that was open) and overlays the popup there.
What am I doing wrong?
My Call Reciver:
public class CallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
Intent i = new Intent(context, IncomingCallPopup.class);
i.putExtras(intent);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
context.startActivity(i);
}
}}
My popup Activity:
public class IncomingCallPopup extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
//getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.call_popup);
String phoneNumber = getIntent().getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
TextView text = (TextView)findViewById(R.id.text);
text.setText("Incoming call from " + phoneNumber);
}
}
What am I missing?