android - 标准调用屏幕上的 Activity 窗口 - 启用按钮

标签 android google-voice

我想在通话屏幕 Activity 中添加一个小窗口(弹出窗口)。 Google 语音worldcallplaceandtime在通话期间都添加了相同的窗口。

问题是当我在屏幕顶部打开一个新 Activity 时,其余按钮被禁用(结束通话、静音等)。单击结束通话按钮的唯一选项仅在我关闭添加的新 Activity 时出现。

谁能告诉我如何在屏幕上添加一个小窗口并且仍然能够使用调用标准按钮?

最佳答案

这是我用来在调用屏幕上添加覆盖按钮而不禁用按钮的代码。 我希望它能帮助..

    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;
    }
}

关于android - 标准调用屏幕上的 Activity 窗口 - 启用按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4078715/

相关文章:

http - 使用直接接入号码调用 Google 语音电话的网址是什么?

documentation - 谷歌语音 API 文档

twilio - Twilio 能否检测到对 Google 语音号码的调用是否被转发到语音邮件或真实的人?

android - 操作栏中的选项卡项宽度 (Android)

android - 将数据从一个 xamarin.android 应用程序发送到另一个 xamarin.forms 应用程序

javascript - 如何更改延迟加载 cordova 应用程序的时间?

python noob 在发送谷歌语音文本时遇到问题

android - 带有模块排除的 gradle 依赖属性

java - Android:isDirectory() 始终返回 true

java - Google Voice 接收新来电通知