views:

624

answers:

1

I was wondering if anyone can tell if how to pop a dialog screen up over a native Android screen?

I currently have an application that traps an outgoing call and stops it, I then want to pop up a dialog that would take over from the dialler screen and alert the user that there attempt to call has been blocked and allow them have some new options from the dialog.

I know that some people will say that I should use notifications instead but I'm aware of that and its not the way that it should work, I need to be able to pop up a dialog when the call gets trapped.

This is my dialog code so far

  AlertDialog LDialog = new AlertDialog.Builder(context)
     .setTitle("Call Blocked")
     .setMessage("Call Blocked, reroute call?")
     .setPositiveButton("ok", null).create();
      LDialog.show();

I presume I have to somehow get the context to be that of the dialler screen?

Can anyone offer any help and assistance or links to tutorials?

Thanks in advance

+5  A: 

For my application I used an activity with the Dialog theme. You can declare the theme in the manifest file :

<activity android:name="PopupActivity"
  android:launchMode="singleInstance" android:excludeFromRecents="true"
  android:taskAffinity="" android:theme="@android:style/Theme.Dialog" />
  • use launcheMode="singleInstance" and taskAffinity="" if your popup is detached from your main application. Otherwise user may click the back button and return to the previous activity of your application.
  • excludeFromRecents="true" to avoid your popup to appear in recent tasks (long press home)
  • theme="@android:style/Theme.Dialog" to set the Dialog theme.
kosokund
Thanks Thomas, that is an excellent solution
Donal Rafferty