17

I want to create a customized popup over the android's incoming call screen where I wish to add information for the user. I want the popup to not disable any clickability from the background so that the user could still answer the call.

I know it is possible since many applications do it, e.g. MeZeZe app: enter image description here

Some more information:

  1. A translucent theme did not work since it cancels the former activity's clickability.
  2. A toast is not an option - I don't want it to disappear.
  3. I know there are many similar threads - I read many of them and none answer my specific problem.
  4. I already know how to "make something happen" once a call is receiver, so no need for INCOMING_CALL activity tips.

Would appreciate any help! Thanks

Guy
  • 5,370
  • 6
  • 25
  • 30

3 Answers3

11

If you want to keep the Call activity still clickable, but not have any controls on your overlay, you can do this by calling

getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);

In the onCreate() method of the activity that is shown over the call.

The layout parameters useable together with this are:

android:windowBackground="@android:color/transparent" 
android:windowIsTranslucent="true" 
android:windowAnimationStyle="@android:style/Animation.Translucent"
Guykun
  • 2,780
  • 23
  • 28
  • Thank you! worked with a little addition. Added it to your response so the answer will be complete. and code in comments is bad :) – Guy Jan 05 '12 at 08:35
  • Is there any way I can take control of the complete screen so I have a customized incoming screen? – user1163234 Mar 05 '12 at 12:31
  • Hi, I have an issue. If i get a call while in my app ( ie any of the view of an activity in my app is in focu ) this is not working properly. The android incoming call screen comes and disappears , with my app activity window displayed and whatever screen overriding i am doing, that is also visible. Please help – png Jun 06 '12 at 11:04
  • Is there any way to show this on lock screen as well? – Rakesh Yadav Mar 08 '17 at 08:59
0

This worked for me with a few additions:

In the BroadcastReceiver I added the following lines to the intent:

        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

Furthermore, I added a delay of roughly 1.5 seconds before I fire PopupWindow activity to make sure it is coming after the incoming call system screen.

In the Manifest file I added:

<activity android:name=".PopUpIncomingCallActivity" 
          android:theme="@android:style/Theme.Translucent">

</activity>

to make sure that the layout of the Popup screen is translucent.

In the Popupscreen layout xml file I added the following propperties:

    android:windowAnimationStyle="@android:style/Animation.Translucent"
    android:windowBackground="@android:color/transparent"
    android:windowIsTranslucent="true"

However this solution still has a drawback:

The Popup screen appears above the incoming call system screen and therefore a user has to perform an action (such as clicking a button, pressing a key or touching the screen) to close the Popup screen, as the incoming call screen remains underneath and is not accessible until the popup screen is closed.

0

It will not only show the activity on lock screen but will also allow to receive an incoming call behind your activity screen.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Window win = getWindow();
    win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    win.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);

    setContentView(R.layout.activity_main);