[android] Can I click a button programmatically for a predefined intent?



Answers

If your button includes any animation, you'll need to perform the click and then invalidate each step after performClick. Here's how:

 button.performClick();
 button.setPressed(true); 
 button.invalidate(); 
 button.setPressed(false); 
 button.invalidate(); 

On occasion I've also had to introduce delay to get the animation to show. Like this:

 //initiate the button
 button.performClick();
 button.setPressed(true); 
 button.invalidate(); 
 // delay completion till animation completes
 button.postDelayed(new Runnable() {  //delay button 
     public void run() {  
        button.setPressed(false); 
        button.invalidate();
        //any other associated action
     }
 }, 800);  // .8secs delay time
Question

I need the button click of the intent ACTION_SEND. Here there is no need of displaying UI. Can I get the "Send" button click from the MMS-SMSProvider in Android?




Related