2017-05-05 1 views
1

마이크를 사용하여 Xamarin.Forms 앱을 개발하고 있습니다. 내 응용 프로그램은 안드로이드 7.1 (누가) 화웨이 P9 - 전화를 사용합니다. 내 안드로이드 매니페스트에는 다음이 포함됩니다.Xamarin.Forms에 Android 권한 대화 상자가 표시되지 않습니다.

마이크를 사용하려고해도 권한 대화 상자가 표시되지 않습니다. 전화 설정에서 권한을 수동으로 설정할 수 있습니다 (앱이 작동하면 앱이 작동 함). 마이크에 액세스

코드는 : 나는 무엇을 놓치고

this.recorder = new MediaRecorder(); 

this.recorder.SetAudioSource(AudioSource.Mic); 
this.recorder.SetOutputFormat(OutputFormat.AmrWb); 
this.recorder.SetAudioEncoder(AudioEncoder.AmrWb); 
this.recorder.SetAudioSamplingRate(16000); 

var directoryName = Configuration.RecordDirectory; 

if (!Directory.Exists(directoryName)) 
{ 
    Directory.CreateDirectory(directoryName); 
} 

var fileName = Configuration.RecordName + Configuration.RecordExtension; 
string path = Path.Combine(Configuration.RecordDirectory, fileName); 

this.recorder.SetOutputFile(path); 
this.recorder.Prepare(); 
this.recorder.Start(); 

?

런타임 중에 대화 상자를 표시하도록 앱을 강제 실행할 수 있습니까?

해결

this blog article 읽기, 개발자들은 안드로이드 marshmellow 때문에 수동으로 권한 요청을 구현해야합니다.

+0

안드로이드 6.0 이후 마이크 – Jason

+0

액세스를 시도하는 코드를 보여주십시오 (대답이 이미 질문에 제공 한 이후 커뮤니티 위키로 추가) https://developer.android.com/training/permissions/requesting.html – Gusman

+0

@jason 귀하의 회신에 감사드립니다. 질문에 코드를 추가했습니다. –

답변

관련 문제