Code example for Semaphore

0
 
import android.graphics.Bitmap; 
import android.view.View; 
 
public class TakePictureCommand extends AutomationElementCommandBase {	 
	 Semaphore finishedFlag = new Semaphore(1);		 
	 String errorMessage = null;
	 byte[] jpegBuffer = null;
	  
	protected void executeImpl() throws TestFrameworkException { 
    	View view = getView(false);
    	 
    	if (view == null)
   		 	view = getRootView();
    	 
    	if (view == null) {
    		sendNotFoundResult(); 
    		return; 
    	} 
    	 
		takeScreenShot(view);