title: Detecting Play Services Installed and Play Services Used in App
body: <p><strong>What I Have</strong></p>
  
  <p>I have an app that <strong>heavily relies on Google Play Services</strong> (for Firebase), so I need the user's device to have Play Services installed. More importantly, the Play Services version installed in the device should be equal to or higher than the Play Services I am using in my app.</p>
  
  <p><strong>What I Want</strong></p>
  
  <p>I want to show a message (maybe a dialog or snackbar) in the Splash screen of my app if the user is using an old Play Services version that the version I am targeting in my app.</p>
  
  <p>Like currently, the version of Play Services I am using in my app is 10.0.1. This is the version name obviously. </p>
  
  <p>I know I can do this,</p>
  
  <pre><code>int v = getPackageManager().getPackageInfo("com.google.android.gms", 0 ).versionName;
  </code></pre>
  
  <p>But I am unable to compare the versions of the Play Services installed in the device and the Play Services I am using? Should I be doing it using the versionCode instead of the versionName? If so, how do I know the versionCode of the Play Services I am using?</p>
  
  <p>Or is there a different (or better) way to do this?</p>