2010-11-02 32 views
3

我想在呼叫屏幕上添加一个小窗口(Popup)。 谷歌语音worldcallplaceandtime都在呼叫期间添加相同的窗口。标准呼叫屏幕上的活动窗口 - 启用按钮

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

任何人都可以请告诉我如何添加一个小窗口一个屏幕,仍然可以使用通话标准按钮?

+0

你有这个问题的任何解决方案吗? @shaimagz – Pinki 2012-05-22 07:15:51

回答

0

这是我用来在呼叫屏幕上添加覆盖按钮而不禁用按钮的代码。 我希望它有助于..

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

如果我使用,我在空闲状态使用removeInvitePopup()时收到异常。关闭邀请按钮不会消失,当你错过了电话