1

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
harwalan
  • 847
  • 2
  • 9
  • 12
  • This should not be possible from application. You can be notified that a phone call comes in, but I don't believe you can cancel the default incoming call screen. Maybe you have to build your own system image or have a bigger screen than the default. – Joe Ho Apr 08 '11 at 09:48

2 Answers2

0

Try:

i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
advantej
  • 20,155
  • 4
  • 34
  • 39
0

An Activity, by design, always takes over the full-screen. If you want your Activity to appear as if it is only partially obstructing the incoming call screen, you may want to attempt making the Activity theme transluscent, as is discussed here.

You may also have to clear the Activity stack (Intent.FLAG_ACTIVITY_CLEAR_TOP) to keep your previously open Activites from hanging out underneath.

Community
  • 1
  • 1
devunwired
  • 62,780
  • 12
  • 127
  • 139