如何启动背景语音处理。模拟器是否支持iOS中的背景模式。
这是我的代码启动背景process.But,它不是working.when,我按下主页按钮录音停止。
-(void)applicationDidEnterBackground:(UIApplication *)application
{
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) { //Check if our iOS version supports multitasking I.E iOS 4
if ([[UIDevice currentDevice] isMultitaskingSupported]) { //Check if device supports multitasking
UIApplication *application = [UIApplication sharedApplication]; //Get the shared application instance
__block UIBackgroundTaskIdentifier background_task; //Create a task object
background_task = [application beginBackgroundTaskWithExpirationHandler: ^ {
[application endBackgroundTask: background_task]; //Tell the system that we are done with the tasks
background_task = UIBackgroundTaskInvalid; //Set the task to be invalid
//System will be shutting down the app at any point in time now
}];
//Background tasks require you to use asyncrous tasks
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//Perform your tasks that your application requires
NSLog(@"\n\nRunning in the background!\n\n");
NSString *pollingTimer2 = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(recordPauseTapped:)
userInfo:nil
repeats:YES];
[application endBackgroundTask: background_task]; //End the task so the system knows that you are done with what you need to perform
background_task = UIBackgroundTaskInvalid; //Invalidate the background_task
});
}
}
}发布于 2013-09-19 07:17:42
若要检查设备是否支持多任务处理,请使用以下代码:
if ([[UIDevice currentDevice] isMultitaskingSupported])虽然模拟器有一些硬件限制,包括:
-Accelerometer
-Gyroscope
-Camera
-Proximity传感器
-Microphone输入
要在设备上测试应用程序,您必须是iOS开发人员程序的成员。要了解有关注册iOS开发人员程序的更多信息,请参见应用程序发行指南中的“注册Apple程序并访问其工具”。您不能在模拟器上测试所有这些特性。
发布于 2013-09-02 09:06:20
不,它不支持背景模式。
发布于 2013-09-02 09:12:11
模拟器支持后台模式,但是您的条件(如下面所示)将在模拟器上失败&因此出现了问题。
如果([UIDevice currentDevice isMultitaskingSupported])
https://stackoverflow.com/questions/18569161
复制相似问题