状态栏中显示灰色GPS箭头,尽管基于位置的应用程序使用快速应用程序切换器终止 [英] Grey GPS arrow shown in statusbar although location based application killed using Fast App Switcher

查看:161
本文介绍了状态栏中显示灰色GPS箭头,尽管基于位置的应用程序使用快速应用程序切换器终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iOS 5编写基于位置的应用程序。该应用程序使用 CLLocationManager 来接收位置更新。

I am writing a location based application for iOS 5. The application is using the CLLocationManager to receive Location updates.

当应用程序启动时,我正在创建LocationManager,调用 [self.locationManager startUpdatingLocation]; 和灰色位置箭头显示在状态栏中。

When the application is started I am creating the LocationManager, calling [self.locationManager startUpdatingLocation]; and the grey location arrow appears in the statusbar.

当应用程序进入后台时,我正在调用

When the application enters background I am calling

[self.locationManager stopUpdatingLocation]; 
[self.locationManager startMonitoringSignificantLocationChanges];

因为我只想在应用程序处于后台时收到重要的位置更改。灰色位置箭头仍然显示。

cause I just want to receive significant location changes while the app is in background. The grey location arrow is still shown.

我的应用程序中还有一个退出按钮,我打电话

I also have an exit button in my application where I am calling

[self.locationManager stopUpdatingLocation];
exit(0);

当用户按下Exit-Button时,应用程序完成,灰色位置按钮从状态栏中消失。到目前为止,一切都很好。

When the user presses the Exit-Button the application finishes and the grey location button disappears from the statusbar. Everythings fine until now.

当用户使用快速应用程序切换器完成应用程序时出现问题,因为之后灰色位置箭头仍然显示在状态栏中,虽然应用程序没有运行。当用户从iPhone移除应用程序时,灰色位置箭头首先消失。

A problem appears, when the users finishes the application using the Fast App Switcher, because afterwards the grey location arrow is still shown in the status bar, although the application isn't running. The grey location arrow first disappears, when the user removes the application from his iPhone.

所以问题是:


  • 当用户使用Fast App Switcher完成应用程序并且状态栏中仍然显示灰色箭头时,这是否意味着仍然执行位置更新,或者这是否意味着应用程序在过去24小时内使用了位置服务?我想答案是第一个,位置更新仍然执行!

  • When the users finishes the application using Fast App Switcher and the grey arrow is still shown in the status bar, does this mean, that location updates are still executed or does this mean, that an application used Location services whithin the last 24 hours? I guess the answer is the first one, location updates are still executed!

应用程序需要在后台执行,所以我无法停止LocationManager当应用程序进入后台时。当用户使用Fast App Switcher杀死应用程序时, applicationWillTerminate:永远不会被调用。当使用快速应用程序切换器终止应用程序或被操作系统终止时,有没有办法接收事件????

The application needs to be executed in background, so I can't stop the LocationManager when the application enters background. applicationWillTerminate: gets never called when the user kills the application using Fast App Switcher. Is there any way to receive an event, when the application is terminated using Fast App Switcher or is terminated by the the OS????

我是看到一些其他应用程序,当使用Fast App Switcher杀死应用程序时,状态栏中的灰色箭头消失。这些应用程序如何实现这一目标???

I've seen some other applications, where the grey arrow in the status bar disappears when the application is killed using Fast App Switcher. How does these applications achieve this???

推荐答案


  1. 如果您的应用不在前台,则可以使用重要的位置更新。


  2. 我只是给你一个想法我做过这样的事情,但我不知道你的情况会发生什么。

    Just注册你的应用程序的后台任务,并做一些测试目的,如果你通过快速应用程序切换杀死你的应用程序然后委托方法 applicationWillTerminate:总是被调用。

  1. Significant Location updates are available if you app is not in foreground.
  2. I just give you an idea I have done something like this but I don't know what happens in your case.
    Just register your app for background task and do some thing for testing purpose in that case if you kill your app via fast app switching then the delegate method applicationWillTerminate: is always called.


_ __ _ __ _ __ _ _ 被修改 _ __ _ __ _ __ _ __ _ _

只需将此varibale添加到AppDelegate.h中


___________Edited______________
just add this varibale into your AppDelegate.h

UIBackgroundTaskIdentifier bgTask;

并制作这样的委托方法,现在杀死你的应用

and make your delegate method like this and now kill your app

    - (void)applicationDidEnterBackground:(UIApplication *)application
    {
        UIApplication *app = [UIApplication sharedApplication];
        if ([app respondsToSelector:@selector(beginBackgroundTaskWithExpirationHandler:)]) {
            bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
                // Synchronize the cleanup call on the main thread in case
                // the task actually finishes at around the same time.
                dispatch_async(dispatch_get_main_queue(), ^{
                    if (bgTask != UIBackgroundTaskInvalid)
                    {
                        [app endBackgroundTask:bgTask];
                        bgTask = UIBackgroundTaskInvalid;
                    }
                });
            }];
        }
    }

- (void)applicationWillTerminate:(UIApplication *)application
{
    NSLog(@"is terminated");
}


_ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ _


_____________________________

这篇关于状态栏中显示灰色GPS箭头,尽管基于位置的应用程序使用快速应用程序切换器终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆