我从GPS设置返回时遇到问题。我想检查GPS是否已启用,但由于某些原因,不仅从调用方Activity调用了onStop(),而且还从onDestroy中调用了该方法,当我从“设置”返回时,由于Activity被销毁,我到达了主屏幕。我不知道是什么触发了此行为,因为在另一个应用程序中,相同的代码起作用并返回。这是一个简单的调用:
case(GPS_SWITCHER):{
Intent intent = new Intent("android.settings.LOCATION_SOURCE_SETTINGS");
//intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivityForResult(intent,REQUEST_CODE);
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用Intent的标志,但是并没有解决问题。我也尝试过从PreferenceActivity调用Intent,但此调用已经终止了Main应用程序:-)有什么想法吗?
谢谢 !
我想知道是否可以在iOS7上同时播放音乐和某种文字转语音引擎.我正在使用Apple的新内置API,其中一个正在运行,而不是两者都有效.有人在想吗?我的TTS播放代码,也在后台工作
-(void)speak:(NSString*)string
{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *setCategoryError = nil;
[audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];
NSError *activationError = nil;
[audioSession setActive:YES error:&activationError];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:string];
utterance.rate = 0.3f;
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:[AVSpeechSynthesisVoice currentLanguageCode]];
AVSpeechSynthesizer *synth = [[AVSpeechSynthesizer alloc] init];
[synth speakUtterance:utterance];
}
Run Code Online (Sandbox Code Playgroud)