androidappboy

handle button1, button2 click in appboy


I am implementing IInAppMessageManagerListener interface and want to handle the method onInAppMessageButtonClicked, but I want to know the button the user pressed (Button1 or Button2) to be able to handle each one with different handling.

How can I do that ?


Solution

  • You can use the button id (with MessageButton.getId() mehtod) to know which one is pressed.

    boolean onInAppMessageButtonClicked(MessageButton button, InAppMessageCloser inAppMessageCloser){
    
         switch(button.getId()){
    
            case button1_id:
                // do button 1 stuff
            break;
    
            case button2_id:
                // do button 2 stuff
            break;
         }
        .....
    }