Cannot get multi camera from Nokia 7 plus - xamarin.android

I use C# xamarin and Nokia 7 plus which install android 9 already. Nokia 7 plus contain zeiss dual back camera. So I think I could get multi camera support
[Activity(Label = "#string/app_name", Theme = "#style/AppTheme", MainLauncher = true)]
public class MainActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
var manager = base.GetSystemService(CameraService) as CameraManager;
var dict = manager.GetCameraIdList().ToDictionary((id) => id,(id) => manager.GetCameraCharacteristics(id));
var lens = dict.Values.Select((characteristics) => (
(LensFacing)((int)characteristics.Get(CameraCharacteristics.LensFacing)),
characteristics.Get(CameraCharacteristics.RequestAvailableCapabilities).ToArray<RequestAvailableCapabilities>(),
characteristics.PhysicalCameraIds.ToArray(),
characteristics.Get(CameraCharacteristics.LensPoseRotation),
characteristics.Get(CameraCharacteristics.LensPoseTranslation),
characteristics.Get(CameraCharacteristics.LensIntrinsicCalibration),
characteristics.Get(CameraCharacteristics.LensRadialDistortion),
characteristics.Get(CameraCharacteristics.LensPoseReference)
)).ToArray();
}
}
This code give me 2 camera with 1 front and 1 back correctly. However the capabilities does not contains LogicalMultiCamera, PhysicalCameraIds is empty set, and all information about lens pose is null
What am I doing wrong here? Or are there any problem about Nokia, Xamarin, or Android SDK?

Related

Xamarin (Android): Detect if the device has a display notch or not

I'm trying to detect if the device my app is running on has a notch or not.
This has what I need but I'm not been able to find the Xamarin equivalent for getDisplayCutout() in the WindowInset class.
There are some differences between native Android and Xamarin.Android .
In your case , the method getDisplayCutout() in Xamarin.Android is readonly property called DisplayCutout .
public DisplayCutout DisplayCutout { get; }
You could access it like
Android.Views.WindowInsets window = new WindowInsets(cpoySrc);
var Cutout = window.DisplayCutout;
cpoySrc is a source WindowInsets. Check https://learn.microsoft.com/en-us/dotnet/api/android.views.windowinsets.-ctor?view=xamarin-android-sdk-9
I managed to 'solve' this issue by measuring the size of the status bar and comparing it against a known/safe threshold.
Won't claim this to be the best solution to this question but it holds up against the devices I've tested so far.
private const int __NOTCH_SIZE_THRESHHOLD = 40; //dp
/// <summary>
/// Device has a notched display (or not)
/// </summary>
public bool HasNotch
{
get
{
// The 'solution' is to measure the size of the status bar; on devices without a notch, it returns 24dp.. on devices with a notch, it should be > __NOTCH_SIZE_THRESHHOLD (tested on emulator / S10)
int id = MainActivity.Current.Resources.GetIdentifier("status_bar_height", "dimen", "android");
if (id > 0)
{
int height = MainActivity.Current.Resources.GetDimensionPixelSize(id);
if (pxToDp(height) > __NOTCH_SIZE_THRESHHOLD)
return true;
}
return false;
}
}
/// <summary>
/// Helper method to convert PX to DP
/// </summary>
private int pxToDp(int px)
{
return (int)(px / Android.App.Application.Context.Resources.DisplayMetrics.Density);
}

AR Kit 3: SupportsFrameSemantics() is returning false on supported iOS device

I am using an iPhone 11 using iOS 13.2.3.
Xcode 11.2.1
Xamarin.iOS V13.6.0.12
The person segmentation does work successfully regardless of API call saying it isn't supported which is strange. I need to be able to detect if it's supported per device to handle devices that don't support arkit 3 human occulsion.
Does anyone else have the same problem?
public override void ViewDidLoad()
{
base.ViewDidLoad();
// All returning false
Debug.WriteLine("Person Segmentation Supported: " + ARWorldTrackingConfiguration.SupportsFrameSemantics(ARFrameSemantics.PersonSegmentation));
Debug.WriteLine("Person Segmentation Depth Supported: " + ARWorldTrackingConfiguration.SupportsFrameSemantics(ARFrameSemantics.PersonSegmentationWithDepth));
Debug.WriteLine("Body Detection Supported: " + ARWorldTrackingConfiguration.SupportsFrameSemantics(ARFrameSemantics.BodyDetection));
}
[Export("renderer:didAddNode:forAnchor:")]
public void DidAddNode(ISCNSceneRenderer renderer, SCNNode node, ARAnchor anchor)
{
// Returns false
Debug.WriteLine("Supported? " + ARWorldTrackingConfiguration.SupportsFrameSemantics(ARFrameSemantics.PersonSegmentationWithDepth));
// Create AR config with Person Segmentation added
var configuration = new ARWorldTrackingConfiguration
{
PlaneDetection = ARPlaneDetection.None,
LightEstimationEnabled = true,
FrameSemantics = ARFrameSemantics.PersonSegmentationWithDepth
};
// Runs the session and the feature works on iPhone 11 regardless of SupportsFrameSemantics(ARFrameSemantics.PersonSegmentationWithDepth) == false
ARView.Session.Run(configuration, new ARSessionRunOptions());
}
https://github.com/xamarin/xamarin-macios/issues/9271
I've opened up an issue ticket on xamarin's github. See Whitneys comment for a work around, she has opened a PR also so expect this to be included in an update soon.

Xamarin.Forms on iOS 11.1.2: Webview loads a bigger font

I'm using Xamarin.Forms to load an internet's webpage (requirements of the client, please don't judge me), the problem is that in iOS the webpage appears to be bigger that it is.
I don't have any custom render on iOS.
Here is the website loaded on safari on a iPhone 6 iOS 11.1.2
And here is loaded on the webview
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Juppie"
x:Class="Juppie.MainPage">
<Grid>
<WebView x:Name="Navegador" Source="http://empleosapp.caonainteractive.com/"
WidthRequest="1000" HeightRequest="1000" IsVisible="{Binding Path=HayInternet}" ></WebView>
<ActivityIndicator IsRunning="{Binding Path=Navegando}" IsVisible="{Binding Path=Navegando}"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.33}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0.33}"/>
</Grid>
</ContentPage>
MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Plugin.Connectivity;
using System.ComponentModel;
namespace Juppie
{
public partial class MainPage : ContentPage, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public MainPage()
{
InitializeComponent();
Navegador.Navigating += Navegador_Navigating;
Navegador.Navigated += (sender, e) => { Navegando = false; };
HayInternet = true;
BindingContext = this;
}
bool hayInternet;
public bool HayInternet
{
get
{
return hayInternet;
}
set
{
hayInternet = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("HayInternet"));
EvaluarInternet();
}
}
bool navegando;
public bool Navegando
{
get
{
return navegando;
}
set
{
navegando = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Navegando"));
}
}
public async void EvaluarInternet(){
if (!HayInternet)
{
await DisplayAlert("Aviso","Se requiere conexion a internet para emplear esta aplicacion", "OK");
}
}
protected override void OnAppearing()
{
HayInternet = CrossConnectivity.IsSupported && CrossConnectivity.Current.IsConnected;
CrossConnectivity.Current.ConnectivityChanged += (sender, args) =>
{
HayInternet = args.IsConnected;
};
base.OnAppearing();
}
protected override bool OnBackButtonPressed()
{
if (Navegador.CanGoBack)
{
Navegador.GoBack();
return false;
}
return base.OnBackButtonPressed();
}
void Navegador_Navigating(object sender, WebNavigatingEventArgs e)
{
Navegando = true;
if (e.Url.Contains("/banner"))
{
e.Cancel = true;
var uri = new Uri(e.Url.Replace("/banner", ""));
Device.OpenUri(uri);
}
}
}
}
I tried with a custom render and set the scalePageToFit = false, without success.
If anyone knows how can I fix this, please let me know.
Xaml: - VerticalOptions="FillAndExpand" seems to fill the HeightRequest and WidthRequest property specification requirements for the WebView to render in a StackLayout - in a Grid it seems to render anyway:
<Grid>
<WebView x:Name="webView"
VerticalOptions="FillAndExpand"
Source="https://www.xamarin.com/"/>
</Grid>
Renderer, ScalesPageToFit is false by default (at least in the simulator with iPhone SE 11.2)
[assembly: ExportRenderer(typeof(WebView), typeof(MyWebViewRenderer))]
namespace MyNamespace.iOS
{
public class MyWebViewRenderer : WebViewRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (NativeView != null && e.NewElement != null)
{
var webView = ((UIWebView)NativeView);
webView.ScalesPageToFit = true;
}
}
}
}
The screenshots below are from the simulator with iPhone SE.
ScalesPageToFit = true:
ScalesPageToFit = false:
Tested on my iPhone 6 and the app was showing the same size of font as Safari.
I also tested with larger system font in the font size in the app and it was not affected with the app font size.
But I did notice that when the activity indicator was running, my font size became smaller and it turned normal after the activity indicator disappear.
Maybe the font size issue was cause by the side effect of any additional stuff like a Nuget packages or Activity indicator?
You could try to use a new empty form and load only the Webview to compare the differences.
By the way, your app appearance is very alike with iPhone with turned on Display Zoom function.
Before turn on Display Zoom:
After turned on Display Zoom:
Is it possible that the sizing is overwritten by the accessability-settings from the iPhone?
See Settings-App -> General -> Accessability -> Bigger Text
(freely translated from german, actual menu entries may be named different)
I have faced the same issue.
In Xamarin.Forms App resolution is based on the Launch screen. If you are using Assets (LaunchImage) for Launch screen. Then your app resolution is set as per LaunchImage.
The best solution is: use storyboard (LaunchScreen.storyboard) or XIB for Launch screen. This improves your App UI. like font size and App resolution

Add webview in Xamarin gtk form

I want to use Webview in Xamarin gtk Form. The problem is that i can't find Webview in toolbox.
Looking at this example i added some code in default MainWindow.cs code.
using System;
using Gtk;
using Xamarin.Forms;
public partial class MainWindow: Gtk.Window
{
public MainWindow () : base (Gtk.WindowType.Toplevel)
{
Build ();
WebView webView = new WebView
{
Source = new UrlWebViewSource
{
Url = "http://blog.xamarin.com/",
},
VerticalOptions = LayoutOptions.FillAndExpand
};
vbox2.Add (webView); //giving error since it webview is not widget.
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Gtk.Application.Quit ();
a.RetVal = true;
}
}
I am new to Xamarin and i don't know i can i create a xamarin gtk# tool that can run on OSX and windows.
I also want to fill htmlDocument and invoke click. Is it possible with xamarin gtk# webview

libgdx - iOS landscape not working right with scene2d

I'm having an issue with libGDX's otherwise great scene2d ui library when running my app in landscape mode. My program works as expected in both the android simulator and the desktop environment, but when I run it on the iOS simulator or a real device, the main menu is drawn as if the phone were still in the portrait orientation, and the just cropped to fit in a landscape view. At first, I assumed I had just screwed up, as I'm still learning the api, but the app works just as expected on android. I have configured my game to run in landscape mode on both iOS and android.
On the android simulator, the menu works as expected. The simulator is in landscape orientation, and properly displays the menu.
On iOS, the menu is off center and unclickable.
I pretty sure that the problem has to do with landscape mode, because everything works fine in portrait orientation. Here's my code for the MainMenuScreen, which extends a ScreenAdapter.
package bakpakin.techgame;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
/**
* Created by Calvin on 9/25/14.
*/
public class MainMenuScreen extends ScreenAdapter {
private TechGame game;
private Stage stage;
private Skin skin;
private Table table;
public MainMenuScreen(TechGame game) {
this.game = game;
}
#Override
public void show() {
this.stage = new Stage();
this.skin = new Skin();
skin.add("default", Assets.superScript48);
skin.add("title", Assets.superScript128);
TextButtonStyle textButtonStyle = new TextButtonStyle();
textButtonStyle.font = skin.getFont("default");
textButtonStyle.pressedOffsetY = 4;
skin.add("default", textButtonStyle);
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = skin.getFont("title");
labelStyle.fontColor = Color.CYAN;
skin.add("default", labelStyle);
// Create a table that fills the screen. Everything else will go inside this table.
table = new Table();
table.setFillParent(true);
stage.addActor(table);
final TextButton play = new TextButton("Play", skin);
final TextButton about = new TextButton("About", skin);
final TextButton quit = new TextButton("Quit", skin);
play.addListener(new ChangeListener() {
#Override
public void changed(ChangeEvent event, Actor actor) {
Assets.button1Sound.play(1, 1, 0);
}
});
about.addListener(new ChangeListener() {
#Override
public void changed(ChangeEvent event, Actor actor) {
Assets.button1Sound.play(1, 1, 0);
}
});
quit.addListener(new ChangeListener() {
#Override
public void changed(ChangeEvent event, Actor actor) {
Assets.button1Sound.play(1, 1, 0);
Gdx.app.exit();
}
});
final Label title = new Label("My Game", skin);
VerticalGroup vg = new VerticalGroup();
vg.pad(60);
table.add(title);
table.row();
table.add(vg);
vg.addActor(play);
vg.addActor(about);
vg.addActor(quit);
Gdx.input.setInputProcessor(stage);
}
#Override
public void render(float delta) {
GL20 gl = Gdx.gl;
gl.glClearColor(0, 0, 0, 1);
gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
stage.act(delta);
stage.draw();
}
#Override
public void dispose() {
stage.dispose();
skin.dispose();
}
}
IOS 7 or 8? I heard there are some iOS 8 rendering issues
Apparently this is fixed in the latest snapshot (see github.com/libgdx/libgdx/issues/2386). With a new stable release promised real-soon-now, I'm sure the fix will be folded in if you're not brave enough to run snapshot builds

Resources