title: Android: How to programatically detect google login popup in Android devices
body: <p><img src="https://i.stack.imgur.com/bKSip.png" alt="enter image description here"></p>
  
  <p>I have tried following monkeyrunner script:</p>
  
  <pre><code>#!/usr/bin/env monkeyrunner 
  from __future__ import with_statement
  import logging
  from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
  from com.android.monkeyrunner.easy import EasyMonkeyDevice
  
  logging.basicConfig(level=logging.DEBUG)
  logger = logging.getLogger(__name__)
  
  if __name__ == '__main__':
      udid = '02f4e07008e40dfc' #sys.argv[1]
      device = MonkeyRunner.waitForConnection(60, udid)
      easyDevice = EasyMonkeyDevice(device)
      logger.info(easyDevice.getFocusedWindowId())
      #h = device.getHierarchyViewer()
      #w = h.getFocusedWindowName()
      #logger.info(w)
  </code></pre>
  
  <p>but I get:</p>
  
  <pre><code>File "./detectGoogleLoginPopup.py", line 19, in &lt;module&gt;
      easyDevice = EasyMonkeyDevice(device)
      java.lang.RuntimeException: Could not connect to the view server
  </code></pre>
  
  <p>I have an <code>ocr</code> way to get to this for now, but would love a monkeyrunner or java api based solution.</p>