Je travaille sur GeoFence et le problème auquel je suis confronté ici est lors de l'utilisation de la mise à jour de la dépendance google service com.google.android.gms: play-services: 7.3.0 geofence message ne fonctionne pas et essayé la méthode possible mentionné dans stackoverflow mais son ne fonctionne pas.Voici le code et me suggérer si c'est faux.Merci à l'avance.Geofence ne fonctionne pas dans le service Google play mis à jour
public class Geofencing implements GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
LocationListener {
private List<GeoRegions> geoRegions;
private GoogleApiClient locationClient;
private Context curr_con;
private boolean location_settings = false;
private static final String TAG = Geofencing.class.getSimpleName();
private Context mContext;
public Geofencing(Context ctx, boolean settings) {
this.curr_con = ctx;
this.location_settings = settings;
}
public void startGeo() {
printedCardNumber = AppUtil.sPxAPI.getTokenInfo()
.getPrintedCardNumber();
locationClient = new GoogleApiClient.Builder(mContext)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
new GetPartSections().execute();
}
private void run_geofence() {
ArrayList<Geofence> mGeoList1 = new ArrayList<Geofence>();
for (GeoRegions georegion : geoRegions) {
Coordinates co = georegion.getCoordinates();
float radius = (float) georegion.getRadius();
Geofence geofence = new Geofence.Builder()
.setRequestId(georegion.getStoreCode())
.setTransitionTypes(
Geofence.GEOFENCE_TRANSITION_ENTER
| Geofence.GEOFENCE_TRANSITION_EXIT)
.setCircularRegion(co.getLatitude(), co.getLongitude(),
radius)
.setExpirationDuration(Geofence.NEVER_EXPIRE).build();
mGeoList1.add(geofence);
}
if (mGeoList1 != null && mGeoList1.size() > 0) {
Intent pIntent = new Intent(curr_con, GeofenceIntentService.class);
pIntent.putExtra("assemble", code);
PendingIntent geoFencePendingIntent = PendingIntent.getService(
curr_con, 0, pIntent, PendingIntent.FLAG_UPDATE_CURRENT);
LocationServices.GeofencingApi.addGeofences(
locationClient,
mGeoList1,
geoFencePendingIntent
).setResultCallback((ResultCallback<Status>) Geofencing.this);
}
}
@Override
public void onLocationChanged(Location location) {
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.e(TAG + ".LocationClientConnectiond", "" + connectionResult);
}
@Override
public void onConnected(Bundle bundle) {
if (geoRegions != null && geoRegions.size() > 0) {
run_geofence();
}
}
@Override
public void onConnectionSuspended(int i) {
}
}
android {
compileSdkVersion 24
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile "fr.avianey.com.viewpagerindicator:library:[email protected]"
compile "com.android.support:recyclerview-v7:24.2.1"
compile "org.twitter4j:twitter4j-core:4.0.2"
compile "com.google.zxing:core:2.0"
compile "com.google.android.gms:play-services:7.3.0"
compile "com.facebook.android:facebook-android-sdk:4.0.1"
testCompile 'junit:junit:4.12'
}
Déposez votre fichier gradle –
posté-Bhuvanesh –
essayer 'compiler « com.google.android.gms: play-services Lieu: 8.4.0'' –