| 1 |
using System; |
| 2 |
|
| 3 |
using Android.App; |
| 4 |
using Android.Content.PM; |
| 5 |
using Android.Runtime; |
| 6 |
using Android.OS; |
| 7 |
using Java.Lang; |
| 8 |
using Android.Hardware.Camera2; |
| 9 |
using Android.Content; |
| 10 |
|
| 11 |
namespace pjsua2xamarin.Droid |
| 12 |
{ |
| 13 |
[Activity(Label = "pjsua2xamarin", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )] |
| 14 |
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity |
| 15 |
{ |
| 16 |
protected override void OnCreate(Bundle savedInstanceState) |
| 17 |
{ |
| 18 |
base.OnCreate(savedInstanceState); |
| 19 |
|
| 20 |
Xamarin.Essentials.Platform.Init(this, savedInstanceState); |
| 21 |
global::Xamarin.Forms.Forms.Init(this, savedInstanceState); |
| 22 |
|
| 23 |
IntPtr class_ref = JNIEnv.FindClass("org/pjsip/PjCameraInfo2"); |
| 24 |
if (class_ref != null) { |
| 25 |
IntPtr method_id = JNIEnv.GetStaticMethodID(class_ref, |
| 26 |
"SetCameraManager", "(Landroid/hardware/camera2/CameraManager;)V"); |
| 27 |
|
| 28 |
if (method_id != null) { |
| 29 |
CameraManager manager = GetSystemService(Context.CameraService) as CameraManager; |
| 30 |
|
| 31 |
JNIEnv.CallStaticVoidMethod(class_ref, method_id, new JValue(manager)); |
| 32 |
|
| 33 |
Console.WriteLine("SUCCESS setting cameraManager"); |
| 34 |
} |
| 35 |
} |
| 36 |
JavaSystem.LoadLibrary("c++_shared"); |
| 37 |
JavaSystem.LoadLibrary("pjsua2"); |
| 38 |
|
| 39 |
LoadApplication(new App()); |
| 40 |
} |
| 41 |
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults) |
| 42 |
{ |
| 43 |
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults); |
| 44 |
|
| 45 |
base.OnRequestPermissionsResult(requestCode, permissions, grantResults); |
| 46 |
} |
| 47 |
} |
| 48 |
} |