iphone - 应用程序崩溃并出现错误 AppName [5811] 被挂起并锁定系统文件 :AddressBook. sqlitedb"

标签 iphone sqlite background addressbook tel

我在我的应用程序中使用地址簿。我正在后台线程中获取通讯录数据。如果我从后台打开我的应用程序,我的应用程序会崩溃并出现以下错误:

    Application Specific Information:
[2786] was suspended with locked system files: 
/private/var/mobile/Library/AddressBook/AddressBook.sqlitedb

在我的应用程序从后台启动后,当我的应用程序收到 UIApplicationDidBecomeActiveNotification 时,我正在后台线程中获取通讯录数据。这是我的代码
    // In my ViewController.m

- (void)viewDidLoad
{
    [[NSNotificationCenter defaultCenter] addObserver:self
                                          selector:@selector(appLaunchedFromBackground:)
                                          name:UIApplicationDidBecomeActiveNotification object:nil];
    // Some more code
}

-(void)appLaunchedFromBackground:(NSNotification *) notification  {

    NSLog(@"In appLaunchedFromBackground");
    [self performSelectorInBackground:@selector(getUpdatedAddressBookData) withObject:nil];
}

-(void)getUpdatedAddressBookData {

    NSLog(@"In %s",__PRETTY_FUNCTION__);

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    AddressBook *addBook = [[AddressBook alloc]init];
    [addBook fetchAddressBookDataInBackground];
    [addBook release];
    [pool drain];
}

我的应用程序中也有 CALL 功能。如果我调用我的应用程序并在通话结束后我再次启动我的应用程序两次我的应用程序崩溃。对于 CALL,我使用了以下代码:
 +(void)makeCallToSelectedContact:(NSString*)phoneNo{

    NSMutableString *phoneNumber = [NSMutableString stringWithString:phoneNo];

    [phoneNumber replaceOccurrencesOfString:@" " 
                                 withString:@"" 
                                    options:NSLiteralSearch 
                                      range:NSMakeRange(0, [phoneNumber length])];
    [phoneNumber replaceOccurrencesOfString:@"(" 
                                 withString:@"" 
                                    options:NSLiteralSearch 
                                      range:NSMakeRange(0, [phoneNumber length])];
    [phoneNumber replaceOccurrencesOfString:@")" 
                                 withString:@"" 
                                    options:NSLiteralSearch 
                                      range:NSMakeRange(0, [phoneNumber length])];

    NSLog(@"phoneNumber => %@",phoneNumber);
    if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNumber]]]) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNumber]]];
    }
    else {
        NSLog(@"Unable to open");
        [self showAlertWithTitle:@"Alert" andMessage:@"This Device Doesn't Support Call Functionality"]; 
    }
}

如何解决崩溃问题?任何形式的帮助都将受到高度赞赏。谢谢。

最佳答案

到目前为止,我发现这似乎是 iOS 6 的一项新保护措施。

当您在发送到后台后继续访问地址簿时,跳板似乎会杀死您的应用程序。当您继续在后台运行以上传一些文件时,可能会发生这种情况。

也可能是这个问题在 6.1 中消失了。日文和中文键盘也有类似的问题,它们访问具有自动完成功能的全局数据库。这个问题在 6.1 中得到了明确的解决,你的问题也很好解决了。

关于iphone - 应用程序崩溃并出现错误 AppName [5811] 被挂起并锁定系统文件 :AddressBook. sqlitedb",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10069295/

相关文章:

html - 如何在IE8中显示部分图像作为背景?

iphone - OpenGL ES iPhone 中的橡皮擦

iPhone以编程方式设置界面方向

objective-c - 从字节偏移检测 UTF NSString 中的字符位置(是 SQLite offsets() 和编码问题)

java - 如何用Java制作一个可移植应用程序(jar+sqlite)?

background - 使用 css sprites 作为标题背景的问题

ios - 是否可以使用NSTimer在后台刷新我的应用程序?

ios - iPhone 应用程序 : "Inject" audio files into phone conversation

iphone - UISplitViewController - 有没有自定义实现的自动旋转方法?

Android 删除 SQL 数据库