Commit 2b1fd6f1 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added permission request for video and audio record

parent 737fa9bc
......@@ -7,12 +7,16 @@ using System.IO;
using Linphone;
using Org.Linphone.Mediastream.Video;
using Xamarin.Forms.Platform.Android;
using Android;
using Android.Util;
using System.Collections.Generic;
namespace Xamarin.Droid
{
[Activity(Label = "Xamarin", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
int PERMISSIONS_REQUEST = 101;
Org.Linphone.Mediastream.Video.Display.GL2JNIView captureCamera;
protected override void OnCreate(Bundle bundle)
......@@ -61,6 +65,37 @@ namespace Xamarin.Droid
LoadApplication(app);
}
protected override void OnResume()
{
base.OnResume();
List<string> Permissions = new List<string>();
if (this.CheckSelfPermission(Manifest.Permission.Camera) != Permission.Granted)
{
Permissions.Add(Manifest.Permission.Camera);
}
if (this.CheckSelfPermission(Manifest.Permission.RecordAudio) != Permission.Granted)
{
Permissions.Add(Manifest.Permission.RecordAudio);
}
if (Permissions.Count > 0)
{
this.RequestPermissions(Permissions.ToArray(), PERMISSIONS_REQUEST);
}
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
{
if (requestCode == PERMISSIONS_REQUEST)
{
int i = 0;
foreach (string permission in permissions)
{
Log.Info("LinphoneXamarin", "Permission " + permission + " : " + grantResults[i]);
i += 1;
}
}
}
}
}
......@@ -33,7 +33,7 @@ namespace Xamarin
if (state == RegistrationState.Ok)
{
register.IsEnabled = false;
this.FindByName<StackLayout>("stack_registrar").IsVisible = false;
stack_registrar.IsVisible = false;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment