title: Android Studio 'Device Only' Location w/ Google Play Services not working
body: <p>I am working on my first app and it is a very simple app. Click button to send Longitude / Latitude to a server/database. I am using Google Play services for location and I am using a Nexus 9 tablet for testing. 
  I have found that using Settings>Location (on Nexus 9) - High Accuracy &amp; Low Accuracy works fine. The data is correct and sent to server. But when choosing 'Device Only'(GPS) it does not find the Long/Lat. I get my toast:</p>
  
  <pre><code>Toast.makeText(MainActivity.this, "Network isn't available", Toast.LENGTH_LONG).show();
  </code></pre>
  
  <p>I am new to this still so I am not sure where I might have gone wrong. I do have the Manifest file w/</p>
  
  <pre><code>uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" 
  </code></pre>
  
  <p>And Google Play Services in my Gradle file. As it does work w/ WiFi anyways.</p>
  
  <p>Also I did put</p>
  
  <pre><code>System.out.println("Longitude (function name)" + longitude + " and Latitude: " + latitude);
  </code></pre>
  
  <p>to view in log when the Long/Lat was being picked up(only when button is clicked, otherwise it's 0.0) In my last test I used High Accuracy and got a Long/Lat. Turned off Wifi and changed locations and it is picking up my new location(but can't send data because no internet connection). So I am confused, as isn't that GPS picking up my new location in High Accuracy?</p>
  
  <p>Not sure if that matters but I would like to have Device Only working for location as well as High Accuracy. 
  Any help would be grateful! Here is my code (shortened, if i am missing anything please let me know to add!) Thanks!</p>
  
  <pre><code>public class MainActivity extends Activity implements ConnectionCallbacks,
      OnConnectionFailedListener {
  
  private GoogleApiClient mGoogleApiClient;
  private Location mLastLocation;
  private Button btnNewShowLocation;
  private double longitude;
  private double latitude;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      if (checkPlayServices()) {
          buildGoogleApiClient();
          //**UPDATED**
          createLocationRequest()
      }
      btnNewShowLocation.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              if (mLastLocation != null) {
                  postDataToServer("web site address- EDIT");
              } else {
                  Toast.makeText(MainActivity.this, "Network isn't available", Toast.LENGTH_LONG).show();
              }}});}
      // **UPDATED** 
      protected void createLocationRequest() {
      mLocationRequest = LocationRequest.create()
              .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
              .setInterval(UPDATE_INTERVAL)
              .setFastestInterval(FATEST_INTERVAL)
              .setSmallestDisplacement(DISPLACEMENT);
  
  private void postDataToServer(String uri) {
  
      RequestPackage p = new RequestPackage();
      p.setMethod("POST");
      p.setUri(uri);
      p.setParam("longitude", String.valueOf(longitude));
      p.setParam("latitude", String.valueOf(latitude));
      MyTask task = new MyTask();
      task.execute(p);
      System.out.println("Longitude (post data to server)" + longitude + " and Latitude: " + latitude);
  
  }
  protected synchronized void buildGoogleApiClient() {
      mGoogleApiClient = new GoogleApiClient.Builder(this)
              .addConnectionCallbacks(this)
              .addOnConnectionFailedListener(this)
              .addApi(LocationServices.API).build();
  }
  private boolean checkPlayServices() {
      int resultCode = GooglePlayServicesUtil
              .isGooglePlayServicesAvailable(this);
      if (resultCode != ConnectionResult.SUCCESS) {
          if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
              GooglePlayServicesUtil.getErrorDialog(resultCode, this,
                      PLAY_SERVICES_RESOLUTION_REQUEST).show();
          } else {
              Toast.makeText(getApplicationContext(),
                      "This device is not supported.", Toast.LENGTH_LONG)
                      .show();
              finish();
          }
          return false;
      }
      return true;
  }
  @Override
  public void onConnected(Bundle arg0) {
      mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
      System.out.println("Longitude (on Connected): " + longitude + " and Latitude: " + latitude);
  
      if (mLastLocation != null) {
          latitude = mLastLocation.getLatitude();
          longitude = mLastLocation.getLongitude();
      } else {
          Toast.makeText(getApplicationContext(), "Searching for your location... \nMake sure WiFi or GPS is turned On", Toast.LENGTH_LONG).show();
      }}}
  </code></pre>
  
  <p>And here is the log notes from High Accuracy on and Wifi turned off. </p>
  
  <pre><code>I/System.out﹕ Longitude (on Connected): 0.0 and Latitude: 0.0
  I/System.out﹕ Longitude (post data to server)-88.7777777 and Latitude: 55.7777777
  W/System.err﹕ java.net.UnknownHostException: Unable to resolve host
  </code></pre>
  
  <p>Wifi is off for that last line.  </p>