Reputation: 1
I need my app to run in background so it can start the alarm and send notification to the user.
I have created one more class called LocalService.java
I extend it with Service and implemented these methods onBind()
, onStartCommand()
and onDestroy()
, on my MainActivity
I have created the whole application which gets the coordinates of the user and updates automatically so it will know when to start the task. The most important stuff is in onCreate()
method, which is mMap.setOnMapClickListener
("mMap" is from private GoogleMap mMap;
) also inside this are mMap.setOnMyLocationChangeListener
and mMap.setOnMarkerClickListener
... BUT the task I want to start is mMap.setOnMyLocationChangeListener
. How I can do this in the LocalService.java
to run in the background?
Upvotes: 0
Views: 66
Reputation: 200
Background Task In iOS8
UIBackgroundTaskIdentifier bgTask;
UIApplication *app = [UIApplication sharedApplication];
if ([app respondsToSelector:@selector(beginBackgroundTaskWithExpirationHandler:)])
{
self.bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
// dispatch_async(dispatch_get_main_queue(),
// ^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if (self.bgTask != UIBackgroundTaskInvalid)
{
NSLog(@"Marking bgTask as Invalid when we entered background");
}
});
}];
}
Upvotes: 3