Activity window on standard call screen - to Enable buttons

霸气de小男生 提交于 2019-12-10 17:55:20

问题


I would like to add a small window (Popup) on call screen activity. Google voice and worldcallplaceandtime are both adding the same window during a call.

The problem is that when I open a new activity on the top part of the screen, the rest of the buttons are disabled (End call, Mute etc). The only option to click the end call button is only when I close the new activity that was added.

Can anyone please tell me how can I add a small window one the screen and still be able to use the call standard buttons?


回答1:


This is the code I used to add an overlay button on the call screen without disabling the buttons. I hope it helps..

    public void addInvitePopup(final String number){
    //check if pref is ok with invite in call
    if(!Preferences.getInstance(getApplicationContext()).getInviteInCall()){return ; }
    // sets the WindowManager
    wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT | 
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    params.x = 250;
    params.height = LayoutParams.WRAP_CONTENT;
    params.width = LayoutParams.WRAP_CONTENT;
    params.format = PixelFormat.TRANSLUCENT;


    params.gravity = Gravity.TOP;
    params.setTitle("Testing");

    ly = new LinearLayout(getApplicationContext());
    ly.setOrientation(LinearLayout.VERTICAL);

    Button inviteButton = new Button(getApplicationContext());
    inviteButton.setClickable(true);
    inviteButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.invite_incall_off));
    inviteButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(v.getContext(), "Inviting by free SMS..", Toast.LENGTH_LONG).show();
            v.setBackgroundDrawable(getResources().getDrawable(R.drawable.invite_incall_on));
            v.setClickable(false);
            sendMessage(v, number);

            //Track this event:
            MixPanelTracking.setPropKeyValue(getApplicationContext(), null, null, "Add friend - During Call");
        }
    });

    //closeInviteButton. ///////////////////////
    closeInviteButton = new Button(getApplicationContext());
    closeInviteButton.setClickable(true);
    //closeInviteButton.setGravity(Button.);
    closeInviteButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.close_invitebutton_off));
    closeInviteButton.setWidth(30);
    closeInviteButton.setHeight(30);
//  closeInviteButton.setLayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
//          WindowManager.LayoutParams.WRAP_CONTENT);

    closeInviteButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            removeInvitePopup();
            //Add to Preferences:
            //Preferences.getInstance(v.getContext()).setInviteInCall(false);
            //Track this event:

        }
    });
    ////////////////////////////////////////////
    ly.addView(inviteButton);

    wm.addView(ly, params);
    wm.addView(closeInviteButton, params);
    Log.i("TTT", "after add view");
}
public void removeInvitePopup(){
    if(ly != null){
        wm.removeView(ly);
        wm.removeView(closeInviteButton);
        ly =  null;
        closeInviteButton = null;
    }
}



回答2:


If I use that i receive an exception when using removeInvitePopup() on IDLE state. Close invite button does not dissapear when you miss the call



来源:https://stackoverflow.com/questions/4078715/activity-window-on-standard-call-screen-to-enable-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!