Xamarin.Forms video renderer restarts - xamarin

I have my own Xamarin.Forms project which I got the video to play but everytime the video is minimized(Home button / lock screen) the video restarts at the beginning. The video plays fine on IOS/recovers fine.
Ive attempted to capture the onPause / OnResume/Onrestart methods in the mainactivity and none of them provide the instance of "videoPlayer"OR "videoPlayerRenderer" with a position higher than 0. So I went and downloaded the provided demo from Xamarin located here Link to MS DOCS. This has the SAME behavior as my modified project(copy/pasted this code anyways).
I have attempted to set the following modes on my MainActivity in the demo Launchmode "LaunchMode = LaunchMode.SingleTask" and have attempted "ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation"
All my tests were run on a Android emulator and also my physical S8+ running OS Android 9.0(pie) in both debug and release versions. I checked my developer settings and nothing is killing the activity "Dont keep Activities" as I saw that in a previous StackOverflow question.

Related

How to ensure that a Xamarin Forms app (AVAudioSessionCategoryPlayback mode) is suspended correctly by iOS to prevent battery drain?

I have a Xamarin Forms app running in AVAudioSessionCategory = Playback mode and it works very nice, background audio is playing and even my timers keep running in the background, which is fine during playback.
How can I ensure that after a user has decided to stop playing audio (either by pressing a button inside of the app or by pressing the pause button on the lock screen) my app will go into a Suspended state and it won't drain the battery?
Is there a way to either force my app to go suspended or a way to verify whether it has?
As a side-note: Hooking the OnSleep method in App.xaml.cs is NOT sufficient because it is being called every time the app goes to the background even if it's playing audio, my timers are running, HTTP calls working, etc.
UPDATE:
Made an interesting discovery today:
Timers keep running running in the background when the app is started from Visual Studio in debug mode (over WiFi).
Timers seem to get suspended automatically by the OS (iOS) when the app enters background in Release mode.
My conclusion is: maybe the entire problem lies somewhere in the 'framework' that is added to the app by Xamarin to ensure communication between Visual Studio and the app? (Console, breakpoints, etc.) It would be a logical explanation.

Problem with Android Silent Notifications that doesn't require user interaction (using GX16 U7 Android SD Generator )

On Android devices (with OS version 6,7,8 or 9) when being inside any application panel, splash screen is always shown when a silent notification arrives. This behaviour cause a nuisance and some confusion to users.
Video Showing this behavior
Until GX16 U6 this was not happening.
Thanks for the report.
This issue is already reported here :
https://www2.genexusnet.com/gxpintranet/hgxpp001.aspx?1,14,96,O,S,0,MNU;E;34;1;MNU;,46930
and it will be solved in the beta channel soon and include in the next release.
Sorry for the inconvenient.

Xamarin Live Player crashes when loading a bitmap, but it runs fine via USB connection

I've been following the examples for using SkiaSharp with Xamarin Forms, particularly the section on using bitmaps. I'm doing this in Microsoft Visual Studio 2017 version 15.9.11. I'm only targeting Android currently.
This page https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/basics/bitmaps has a section on Loading a Bitmap Resource, where the bitmap is an embedded image resource in the project.
So, we add the image and make it type 'embedded resource'
and then run the example code to simply display the image on the canvas.
string resourceID = "SkiaTest.Media.monkey.png";
Assembly assembly = GetType().GetTypeInfo().Assembly;
using (Stream stream = assembly.GetManifestResourceStream(resourceID))
{
resourceBitmap = SKBitmap.Decode(stream);
}
All pretty simple, and it works fine if I run the code on my phone if it is connected via USB in the standard way (a Sony Z5) so the second in the list here, not the Player:
Here it is working via USB:
But if I try and use Xamarin Live Player (the first in the list above) then it crashes on this line:
using (Stream stream = assembly.GetManifestResourceStream(resourceID))
Note that the app runs fine in Live Player if I don't try and load the bitmap, it's only that line that triggers the crash, and only in Live Player.
So I wonder if anyone has any ideas what could be causing Live Player to fail over this issue? Is the resource not being copied to the phone? Does Live Player just not support this type of activity?
The reason you are facing this issue is that Embedded Resources are not yet supported by Xamarin Live player which is causing this exception.
More details can be found in the Troubleshooting Xamarin Live Player document.

Xamarin Forms - how to get app to resume to same view onResume

Since I've implemented a splash activity in my XF app I cannot get the view to persist an app minimize/resume. It worked fine with just one activity. Currently, as per Microsoft's documentation, I have them as mainlauncher- true, nohistory - true in splash activity, false in the other. Anyone experience anything similar?
this is only an issue on android.
Running cross-platform 3.1

Deployment of app to device failed

I have Xamarin Live Player up and running.
When I use it with a newly created Xamarin Forms (Master Details) app, it works fine. I see the app on the device.
However, when I try to run my full-blown app, Visual Studio tells me "Deployment to device failed. Make sure that Xamarin Live Player is open and that the device is in the same network."
Since the new app runs fine, I guess something else is the problem.
I've already set the Android project properties to be same as the newly created app.
Just to make sure, I've made it so that my full-blown app requests all rights.
How could I debug more in detail what's going wrong?
Xamarin Live Player can't run all apps. As soon as you use reflection, embedded resources, a MVVM framework or a custom renderer in Xamarin.Forms it might simply just not run the App.
You can read about the limitations of Xamarin Live Player in the official documentation for it.
You will probably have a much better experience just running directly on the device without Live Player.

Resources