title: Problems with mock allocation
body: <p>Im trying to build a FakeGPS for all my apps, but my apk doesnt appear in mock allocation apps.</p>
  
  <p>I created a Main Activity with a Service to do it, the service is in the Manifest.</p>
  
  <p>What can I do?</p>
  
  <p>EDITED: I put my source code (im new programming in Android, thnx for your help!)</p>
  
  <p>Manifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      package="com.example.fakegps"&gt;
  
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
      &lt;uses-permission android:name="android.permission.ACCES_MOCK_LOCATION" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"
          tools:ignore="AllowBackup,GoogleAppIndexingWarning"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;service android:name=".mockLocationService" /&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>MainActivity.java</p>
  
  <pre><code>package com.example.fakegps;
  import android.Manifest;
  import android.content.Intent;
  import android.content.pm.PackageManager;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.Toast;
  import com.google.android.gms.maps.model.LatLng;
  
  
  public class MainActivity extends AppCompatActivity
  {
      public static LatLng latlong = new LatLng(10,10);
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)
          {
              requestPermissions(new  String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 1);
              return;
          }
          else
          {
              startProveedorUbicacion();
          }
      }
  
      @Override
      protected void onStart()
      {
          super.onStart();
      }
  
      @Override
      protected void onStop()
      {
          super.onStop();
      }
  
      public void startProveedorUbicacion()
      {
          Intent intent = new Intent(this, mockLocationService.class);
          intent.putExtra(mockLocationService.LAT_LNG.toString(), latlong);
          startService(intent);
      }
  
      public void permissionsRequest(int codigoPeticion, String permisos[], int[] resultado)
      {
          if(resultado.length &gt; 1 &amp;&amp; resultado[0] == PackageManager.PERMISSION_GRANTED)
          {
              Toast.makeText(this, "Tienes permisos de localizacion", Toast.LENGTH_SHORT).show();
              startProveedorUbicacion();
          }
          else
          {
              Toast.makeText(this, "No tienes permisos de localizacion", Toast.LENGTH_SHORT).show();
              finish();
          }
  
      }
  }
  </code></pre>
  
  <p>mockLocationService.java</p>
  
  <pre><code>package com.example.fakegps;
  
  import android.app.Service;
  import android.content.Context;
  import android.content.Intent;
  import android.location.Location;
  import android.location.LocationListener;
  import android.location.LocationManager;
  import android.os.Bundle;
  import android.os.IBinder;
  import android.os.SystemClock;
  
  import com.google.android.gms.common.ConnectionResult;
  import com.google.android.gms.common.api.GoogleApiClient;
  import com.google.android.gms.location.FusedLocationProviderApi;
  import com.google.android.gms.location.LocationServices;
  import com.google.android.gms.maps.model.LatLng;
  
  public class mockLocationService extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener
  {
      public static LatLng LAT_LNG;
      private String locationProviderName = "FakeGPS";
      private GoogleApiClient apiClient = null;
      private Location loc;
  
      @Override
      public IBinder onBind(Intent intent)
      {
          return null;
      }
  
      @Override
      public int onStartCommand(Intent intent, int flags, int startId)
      {
          String latlong = intent.getParcelableExtra(MainActivity.latlong.toString());
          if(latlong == null)
          {
              this.stopSelf();
              return Service.START_REDELIVER_INTENT;
          }
  
          createApi();
          apiClient.connect();
  
          LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
          pepareProvider(lm);
          lm.isProviderEnabled(locationProviderName);
          actualizarLocalizacion(lm);
  
          return Service.START_REDELIVER_INTENT;
      }
  
      private void createApi()
      {
           apiClient = new GoogleApiClient.Builder(this)
                  .addConnectionCallbacks(this)
                  .addOnConnectionFailedListener(this)
                  .addApi(LocationServices.API)
                  .build();
      }
  
      void pepareProvider(LocationManager lm)
      {
          lm.addTestProvider(locationProviderName, false, false, false, false, true, true, true, 0, 0);
          lm.setTestProviderEnabled(locationProviderName, true);
      }
  
      public void addConnectionCallbacks()
      {
  
      }
  
      @Override
      public void onConnected(Bundle bundle)
      {
  
          LocationServices api = (LocationServices) LocationServices.FusedLocationApi;
  
          ((FusedLocationProviderApi) api).setMockMode(apiClient,true);
          loc = createLocation();
          ((FusedLocationProviderApi) api).setMockLocation(apiClient, loc);
      }
  
      @Override
      public void onConnectionSuspended(int i) {}
  
      private Location createLocation()
      {
          loc = new Location(locationProviderName);
          loc.setLatitude(LAT_LNG.latitude);
          loc.setLongitude(LAT_LNG.longitude);
          loc.setAccuracy(0);
          loc.setTime(SystemClock.elapsedRealtimeNanos());
          return loc;
      }
  
      private void actualizarLocalizacion(LocationManager lm)
      {
          lm.setTestProviderLocation(locationProviderName, loc);
      }
  
  
      @Override
      public void onLocationChanged(Location location) {}
  
      @Override
      public void onStatusChanged(String provider, int status, Bundle extras) {}
  
      @Override
      public void onProviderEnabled(String provider) {}
  
      @Override
      public void onProviderDisabled(String provider) {}
  
      @Override
      public void onConnectionFailed(ConnectionResult connectionResult) {}
  }
  </code></pre>
  
  <p>build.gradle</p>
  
  <pre><code> apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 28
      defaultConfig {
          applicationId "com.example.fakegps"
          minSdkVersion 27
          targetSdkVersion 28
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      //implementation 'com.android.support:appcompat-v7:27.1.1'
      implementation 'com.android.support.constraint:constraint-layout:1.1.3'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
      implementation 'com.google.android.gms:play-services-maps:8.1.0'
      implementation  'com.google.android.gms:play-services:8.1.0'
  }
  </code></pre>