I'm trying to build a simple app that calls a number when I get to a location. I am using an IntentService with ResultReceiver. Everything is working fine when the app is visible, but nothing is working when the app is on the background. Notifications are not what I need. I need to make a call action. Is that even possible on API 26?
Added a service:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
0, notificationIntent, 0);
Notification notification = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
.setContentTitle("Example Service")
.setContentIntent(pendingIntent)
.build();
startForeground(1, notification);
mReceiver = GeoFenceHandler.mGeoFenceReceiver;
GeofencingEvent geoFenceEvent = GeofencingEvent.fromIntent(intent);
if (geoFenceEvent.hasError()) {
int errorCode = geoFenceEvent.getErrorCode();
deliverResultToReceiver(FAILURE_RESULT, "Error" + errorCode);
} else {
int transitionType = geoFenceEvent.getGeofenceTransition();
//User enter transition
if (Geofence.GEOFENCE_TRANSITION_ENTER == transitionType) {
deliverResultToReceiver(SUCCESS_RESULT, ENTER_AREA);
//User exit transition
} else if (Geofence.GEOFENCE_TRANSITION_EXIT == transitionType) {
deliverResultToReceiver(SUCCESS_RESULT, LEFT_AREA);
}
}
stopSelf();
return START_NOT_STICKY;
}
But still, nothing happens on background.
Thank you.