I have created one Xamarin.forms application that runs URL in webview. The app is a digital signage player, So Android TV/Box will run forever.
I found that after 2-3 days the webview either became unstable/hang/crash. I have tried almost all the types of flags but none of them are working.
Some android TV/Box uses com.google.android.webview and some com.android.webview.
Video Android box (Android 7.1 API 25): https://drive.google.com/file/d/1EU7Vf39wFxStNCGJPHyk519G4ifhSEUw/view?usp=sharing
Log (Check Time stamp: 10-21 14:32:36.278 16584): https://drive.google.com/file/d/16bt1vKYNo02Rm9GQA_Hw-PUV36vDvif3/view?usp=sharing
Anyone have any solution?
MyWebClient client = new MyWebClient();
MyWebChromeClient client2 = new MyWebChromeClient();
webView.SetWebViewClient(client);
webView.SetWebChromeClient(client2);
webView.Settings.JavaScriptEnabled = true;
WebSettings webSettings = webView.Settings;
if (Android.OS.Build.VERSION.SdkInt > BuildVersionCodes.Kitkat)
{
webSettings.BuiltInZoomControls = true;
webSettings.SetSupportZoom(false);
webSettings.DisplayZoomControls = false;
if (Element.AspectRatio)
webView.SetInitialScale(100);
}
webSettings.SetPluginState(WebSettings.PluginState.On);
webSettings.SaveFormData = false;
webSettings.SavePassword = false;
webSettings.AllowFileAccess = true;
webSettings.CacheMode = CacheModes.Default;
webSettings.DatabaseEnabled = true;
webSettings.DomStorageEnabled = true;
webSettings.AllowContentAccess = true;
webSettings.AllowFileAccessFromFileURLs = true;
webSettings.AllowUniversalAccessFromFileURLs = true;
webSettings.BlockNetworkImage = false;
webSettings.BlockNetworkLoads = false;
webSettings.JavaScriptEnabled = true;
webSettings.LoadWithOverviewMode = true;
webSettings.UseWideViewPort = true;
webSettings.SetAppCachePath(this.Context.CacheDir.AbsolutePath);
webSettings.SetAppCacheEnabled(true);
webSettings.LoadsImagesAutomatically = true;
webSettings.MixedContentMode = MixedContentHandling.AlwaysAllow;
webSettings.SetEnableSmoothTransition(true);
if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
{
//This flag is for the android box as those are rooted. It's the same displayed on the above video link.
if (MainActivity.IsRootedDevice)
webView.SetLayerType(LayerType.Software, null);
else
webView.SetLayerType(LayerType.Hardware, null);
}
else
{
// older android version, disable hardware acceleration
webView.SetLayerType(LayerType.Software, null);
}
Related
I have set play/pause button enabled and also added target event to each but when ever I click button in simulator it always calls play button's target event and button's image not properly updating from play to pause and vice versa. Any one have idea regards this?
Note: To play/pause audio I have used Plugin.MediaManager.Forms nuget (version 0.9.7)
[Export("playableContentManager:initiatePlaybackOfContentItemAtIndexPath:completionHandler:")]
public override void InitiatePlaybackOfContentItem(MPPlayableContentManager contentManager, NSIndexPath indexPath, Action<NSError> completionHandler)
{
DispatchQueue.MainQueue.DispatchAsync(() =>
{
UIApplication.SharedApplication.EndReceivingRemoteControlEvents();
UIApplication.SharedApplication.BeginReceivingRemoteControlEvents();
var song = CarPlaylist[indexPath.Section].episodes[indexPath.Row];
var NowPlayingInfoCenter = MPNowPlayingInfoCenter.DefaultCenter;
MPNowPlayingInfo playingInfo = new MPNowPlayingInfo();
playingInfo.Title = song.Title;
playingInfo.Artist = song.Editor;
playingInfo.PlaybackDuration = song.Duration.TotalSeconds; //provide time in seconds
playingInfo.MediaType = MPNowPlayingInfoMediaType.Audio;
playingInfo.Artwork = new MPMediaItemArtwork(image: ExtractArtWork.UIImageFromUrl(song.ArtWork));
playingInfo.AssetUrl = new NSUrl(song.FileUrl.AbsolutePath);
playingInfo.PlaybackRate = song.IsPlaying ? 1.0 : 0.0;
NowPlayingInfoCenter.NowPlaying = playingInfo;
var currentPlayItemId = episode.PodcastId.ToString();
string[] identifier = new string[1];
identifier[0] = currentPlayItemId;
contentManager = MPPlayableContentManager.Shared;
contentManager.NowPlayingIdentifiers = identifier;
contentManager.DataSource = new AppDelegateDataSource(CarPlaylist);
var commandCenter = MPRemoteCommandCenter.Shared;
commandCenter.PlayCommand.Enabled = true;
commandCenter.PauseCommand.Enabled = true;
commandCenter.PlayCommand.AddTarget(PlayButton);
commandCenter.PauseCommand.AddTarget(PauseButton);
completionHandler(null);
UIApplication.SharedApplication.EndReceivingRemoteControlEvents();
UIApplication.SharedApplication.BeginReceivingRemoteControlEvents();
});
}
public MPRemoteCommandHandlerStatus PlayButton(MPRemoteCommandEvent commandEvent)
{
//Logic to update app UI to play mode and play audio
return MPRemoteCommandHandlerStatus.Success;
}
public MPRemoteCommandHandlerStatus PauseButton(MPRemoteCommandEvent commandEvent)
{
//Logic to update app UI to pause mode and pause audio
return MPRemoteCommandHandlerStatus.Success;
}
I am writing a WPF UserControl that hosts a RemoteApp session using the AxMSTSCLib library. I'm using the information from this SO question. The code I wrote is very close to the answer of that question.
I placed the RemoteApp ActiveX (axMsRdpClient9NotSafeForScripting1) inside my WPF UserControl, and provide the necessary parameters when connecting.
But the problem is that the WPF Window that contains the UserControl opens but is blank. The RemoteApp actually launches but in a separate window, outside the main WPF Window. How can I ensure the remote app opens inside the WPF UserControl? What am I missing?
Here is my code:
public void Connect()
{
try
{
axMsRdpClient9NotSafeForScripting1.UserName = #"domain\username";
axMsRdpClient9NotSafeForScripting1.Domain = "GTCS";
axMsRdpClient9NotSafeForScripting1.AdvancedSettings7.ClearTextPassword = "password";
axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.AuthenticationLevel = 2;
axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.EnableCredSspSupport = true;
axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.NegotiateSecurityLayer = false;
axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RDPPort = 3389;
axMsRdpClient9NotSafeForScripting1.Server = "GT-DZ1-ATLS.GTCS.LOCAL"; // 10.24.141.199
axMsRdpClient9NotSafeForScripting1.RemoteProgram2.RemoteProgramMode = true;
axMsRdpClient9NotSafeForScripting1.OnConnected += (o, e) =>
{
m_connectionState = axMsRdpClient9NotSafeForScripting1.Connected;
((ITSRemoteProgram)((IMsRdpClient9)axMsRdpClient9NotSafeForScripting1.GetOcx()).RemoteProgram).ServerStartProgram(#"||startchrome", "", "", true, "", false);
//axMsRdpClient9NotSafeForScripting1.RemoteProgram.ServerStartProgram(#"||startchrome", "", "", true, "", false);
};
axMsRdpClient9NotSafeForScripting1.AdvancedSettings7.PublicMode = false;
axMsRdpClient9NotSafeForScripting1.DesktopWidth = SystemInformation.VirtualScreen.Width;
axMsRdpClient9NotSafeForScripting1.DesktopHeight = SystemInformation.VirtualScreen.Height;
axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.SmartSizing = true;
IMsTscNonScriptable secured = (IMsTscNonScriptable)axMsRdpClient9NotSafeForScripting1.GetOcx();
secured.ClearTextPassword = "password";
axMsRdpClient9NotSafeForScripting1.AdvancedSettings7.ClearTextPassword = "password";
axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RedirectClipboard = true;
axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RedirectPrinters = true;
axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RedirectPorts = false;
axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RedirectSmartCards = true;
axMsRdpClient9NotSafeForScripting1.AdvancedSettings9.RedirectDrives = true;
axMsRdpClient9NotSafeForScripting1.Visible = true;
axMsRdpClient9NotSafeForScripting1.Enabled = true;
axMsRdpClient9NotSafeForScripting1.Connect();
m_connectionState = axMsRdpClient9NotSafeForScripting1.Connected;
}
catch (Exception ex)
{
var err = ex.Message;
MessageBox.Show(ex.Message);
}
I am attempting to create a console app to create a VPN connection for my company. I am able to create the VPN connection but unable to set a few of the properties. I want Unencrypted password (PAP) to be true and CHAP and CHAP2 to be false. But, the opposite is happening to those settings. I am using DotRas tools. What am i doing wrong or missing?
string VpnName = "Test VPN";
string Destination = "127.0.0.1";
string PresharedKey = "testkey";
RasPhoneBook PhoneBook = new RasPhoneBook();
PhoneBook.Open();
RasEntry VpnEntry = RasEntry.CreateVpnEntry(VpnName, Destination, DotRas.RasVpnStrategy.L2tpOnly, DotRas.RasDevice.Create(VpnName, DotRas.RasDeviceType.Vpn));
VpnEntry.Options.UsePreSharedKey = true;
VpnEntry.Options.UseLogOnCredentials = false;
VpnEntry.Options.RequirePap = true;
VpnEntry.Options.RequireMSChap = false;
VpnEntry.Options.RequireMSChap2 = false;
PhoneBook.Entries.Add(VpnEntry);
VpnEntry.UpdateCredentials(RasPreSharedKey.Client, PresharedKey);
Console.WriteLine("VPN connection created successfully");
You can change the three security checkboxes using a combination of options.
VpnEntry.Options.RequireEncryptedPassword = false;
VpnEntry.Options.RequirePap = true;
VpnEntry.Options.RequireChap = false;
VpnEntry.Options.RequireMSChap = false;
VpnEntry.Options.RequireMSChap2 = false;
Those options will have PAP checked, CHAP unchecked, and MS-CHAP v2 unchecked.
You can connect using the the Windows building dialing command "rasdial.exe", using some code like this :
rasDialFileName = Path.Combine(WinDir, "rasdial.exe");
try
{
string args = $"{connectionName} {userName} {passWord}";
ProcessStartInfo myProcess = new ProcessStartInfo(rasDialFileName, args);
myProcess.CreateNoWindow = true;
myProcess.UseShellExecute = false;
Process.Start(myProcess);
}
catch (Exception Ex)
{
Debug.Assert(false, Ex.ToString());
}
Just noticed the title gets shown top and bottom of the toast now in a C# application I'm building. Anyone else see the same thing? In pre-anniversary Windows 10, the BalloonTipTitle only appeared in the top portion of the toast.
Not a big deal, but it looks silly.
I can't post pictures yet, but if I get any responses I'll upload pre and post-anniversary pictures of the toast behavior.
I think I'm getting downvoted because it wasn't really a question. So I'll rephrase:
Windows 10 Anniversary is putting the BalloonTipTitle at the top, and assembly: AssemblyTitle from AssemblyInfo.cs at the bottom of the toast.
What's the best way to manage this across different versions of Windows 10 and 7? I want my user to know my app caused the toast, but I don't want to duplicate information.
Here's some quick code in a Windows Forms Application that shows what I mean. If you change the BalloonTipTitle to match your solution name, you'll see the redundant title:
static void Main()
{
NotifyIcon myNotifyIcon = new NotifyIcon();
myNotifyIcon.BalloonTipIcon = ToolTipIcon.Warning;
myNotifyIcon.BalloonTipText = "This is a test toast";
myNotifyIcon.BalloonTipTitle = "Toast Title";
myNotifyIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
myNotifyIcon.Visible = true;
myNotifyIcon.ShowBalloonTip(10000);
ContextMenuStrip contextMenu = new ContextMenuStrip();
ToolStripMenuItem menuItemExit = new ToolStripMenuItem();
menuItemExit.Text = "Exit";
contextMenu.Items.Add(menuItemExit);
menuItemExit.Click += delegate { myNotifyIcon.Visible = false; Application.Exit(); };
myNotifyIcon.ContextMenuStrip = contextMenu;
System.Timers.Timer myTimer = new System.Timers.Timer();
myTimer.Interval = 20000;
myTimer.Enabled = true;
myTimer.Elapsed += delegate { myNotifyIcon.ShowBalloonTip(10000); };
Application.Run();
}
Decided to check the CurrentBuild registry key after checking for Windows 10. Anything greater than or equal to build 14393 (Anniversary), and I'll leave out the BalloonTipTitle
bool AppNameInBaloon = false;
string BuildString = ReadHKLMValue(#"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuild");
int CurrentBuild;
bool WasParsed = Int32.TryParse(BuildString, out CurrentBuild);
if (WasParsed)
{
if (CurrentBuild >= 14393)
{
AppNameInBaloon = true;
}
}
private static string ReadHKLMValue(string regPath, string value)
{
RegistryKey localKey;
if (Environment.Is64BitOperatingSystem)
{
localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
}
else
{
localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
}
string keyValue;
try
{
keyValue = localKey.OpenSubKey(regPath).GetValue(value).ToString();
return keyValue;
}
catch
{
keyValue = "";
}
return keyValue;
}
I'm trying to capture frames from a camera(usb or raspberrp pi camera) and process them in various ways. I've tried using the MediaCapture Object but it seems like it needs to be tied to the UI. The frames are not being viewed on a UI or saved on any type of storage. They will just be processed and thrown out.
var cameraDevice = await FindCameraDevice();
if (cameraDevice == null)
{
IsInitialized = false;
return false;
}
var settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id };
mediaCapture = new MediaCapture();
try
{
await mediaCapture.InitializeAsync(settings);
IsInitialized = true;
return true;
}
catch{}
Any ideas how I can accomplish this?