Xamarin Image Source - c#

Apologies if this was asked before.
I am having a rather simple issue, and I am wondering if i am missing something obvious. In my practice Xamarin.Forms app, I am having issue loading the following image source URI: http://lorempixel.com/1920/1080/sports/7/ even though when i go there via my browser; it is fine.
It seems to me like Xamarin needs an image extension for it to work, so for example if i were to have some sort of image online like (https://www.stickpng.com/assets/images/58b061138a4b5bbbc8492951.png , fair warning; this link will download the cat image if you go to it) then it loads up fine.
My question is two fold: Am I missing something simple in my configuration that I need to enable (this is for Android as I don't have an iOS device available atm), and B: Does xamarin even support relative paths?
Code Behind:
var source = new UriImageSource
{
Uri = new Uri("http://lorempixel.com/1920/1080/sports/7/")
};
source.CachingEnabled = false;
ImageOne.Source = source;

Explanation
Both iOS & Android now require https:
Apple will require HTTPS connections for iOS apps by the end of 2016
“Today, I’m proud to say that at the end of 2016, App Transport Security is becoming a requirement for App Store apps,” Apple’s head of security engineering and architecture, Ivan Krstic, said during a WWDC presentation
Android P Will Default to HTTPS Connections for All Apps
[Android P] will default to blocking HTTP traffic in apps by default
Answer
It should be an easy fix - change http to https:
var source = new UriImageSource
{
Uri = new Uri("https://lorempixel.com/1920/1080/sports/7/")
};
source.CachingEnabled = false;
ImageOne.Source = source;

Related

Performance considerations when getting license information for WP app

Introduction
I have a Windows Phone 8.1 Silverlight (WP8.1 SL) based app in the store. Some users complain about performance issues when they have a bad network connection. I searched a bit and came up with the idea that it might be related to new LicenseInformation() that gives me the information of whether the app is running in Trial mode or not. The question is, whether this requires network information or not, and whether CurrentApp.LicenseInformation is a suitable replacement for a WP8.1 SL app.
Background and What I did so far
In general, the app does not need a network connection (no data to load, no advertisements, ...). To confirm that I used Fiddler to watch over the network sent by my phone. The result was that no network traffic is generated. However, the problem still persists.
After a lot of research and playing around I got the feeling that this issue might be related to the code part that checks on whether the app is in trial mode or not. I use the following code to check that.
var li = new LicenseInformation();
if (li.IsTrial()) {
...
}
I do this a couple of times during startup. So in case IsTrial() requires a network connection this could be the actual issue when there is only a bad connection available. But again, I couldn't find anything using Fiddler. The documentation (see here) for LicenseInformation does not mention whether a network connection is required or not.
Searching around I found that there is an updated interface available for both WP 8.1 SL and also W10M UWP.
var li = CurrentApp.LicenseInformation;
if (li.IsTrial) {
...
}
Its documentation clearly states that there is no network connection required for that (see here).
Even though the docs say that CurrentApp.LicenseInformation is also available on WP8 I also found some references that say that you only get a reliable answer for the IsTrial-question when using new LicenseInformation() (e.g. here).
Actual Questions
Is new LicenseInformation() required on WP8.1 SL, or can I use CurrentApp.LicenseInformation as well?
Does new LicenseInformation() require a network connection compared to CurrentApp.LicenseInformation?

Not possible to bypass proxy on UWP mobile device?

I am fairly new to UWP apps development and I created simple UWP app (mainly targeting phones) for purpose of testing and demonstrating behavior of Http libraries on UWP (like System.Net.Http).
One of the scenarios should demonstrate bypassing proxy
var httpClientHandler = new HttpClientHandler();
httpClientHandler.UseProxy = false;
httpClient = new System.Net.Http.HttpClient(httpClientHandler);
var response = await httpClient.SendAsync(request);
but the request send using this setting still goes through proxy (proxy is set in Internet APN settings on the phone).
So I am a bit confused here and feel like I am missing something, and I hope someone will be kind enough to answer me a few questions to help me get the right picture :).
1.) I read documentation and some articles on the topic and there is often mentioned System or Default proxy (usualy it says about IE settings). So what does it mean in context of Windows 10? Is it the proxy set in Settings/Network&Internet/Proxy?
1.1) Is there an equivalent on W10 phone?
2.) Is there some other way how to bypass the Internet APN proxy on mobile device, or it is simply not possible and the UseProxy property is just useless in UWP phone apps?
Thanks in advance for your answers :).
Link to original question on msdn boards
What I read behore asking here:
MSDN documentation on related classes and
Article by program manager on the Windows Networking API
The preferred HTTP API in UWP apps is Windows.Web.Http, you can try:
var handler = new HttpBaseProtocolFilter():
habdler.UseProxy = false;
var client = new HttpClient(handler);

GMap .net offline

I'm developing an application using Gmap in c# (great API, btw), not to confuse with google-map API, and I did some really cool and useful stuff ever since.
My problem is that some of my clients won't have an internet connection, and that is why I need to be able to display the background (the map) offline. I used to use the property GMap.NET.AccessMode.ServerAndCache; to get my data from the server, and now I would like to be able to use GMap.NET.AccessMode.CacheOnly with a full cache.
Letting them load the cache with a connection to prepare for an offline use is not an option, the PCs will never be connected to the internet. After some research, I learned OpenStreetMap is the only open source map that would allow me to use their map for free (and that is good because they have very good maps). I downloaded a 20GB map of Europe, but I have no idea how to specify it as the cache (I know how to locate the cache folder).
Most of the time, my Google searches showed me people trying to create a virtual sqlite server with all the map's tiles in a DB accessed via localhost, but honestly I think this is very complex and I would like to know if anybody has an idea to allow me to use those maps offline or a link for the doc of this api, impossible to find on the net (I found the sources, but almost no comment and no explanation).
Thanks in advance, and sorry for my bad English.
réponses en français bienvenues.
you can create a separate program to prefetch tiles for offline use. Or use the GMap NET demo program (https://github.com/radioman/greatmaps/tree/master/Demo.WindowsPresentation)
The code below is for a button press after you've selected an area using ALT + mouse first button.
RectLatLng area = mapView.SelectedArea;
if (!area.IsEmpty)
{
for (int i = (int)mapView.Zoom; i <= mapView.MaxZoom; i++)
{
TilePrefetcher obj = new TilePrefetcher();
obj.Title = "Prefetching Tiles";
obj.Icon = this.Icon;
obj.Owner = this;
obj.ShowCompleteMessage = false;
obj.Start(area, i, mapView.MapProvider, 100);
}
DialogResult = true;
Close();
}
else
{
MessageBox.Show("No Area Chosen", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
(mostly copied from Gmap NET Demo source)
https://github.com/radioman/greatmaps/tree/master/Demo.WindowsPresentation
The Files are stored in C:\Users\[your user name]\AppData\Local\GMap.NET\TileDBv5\en
Once you've successfully prefetched the tiles you can copy the files to the same location in the offline pc and it should use it (or just copy the whole GMap.NET folder to the offline pc via usb or whatever)
use gmap.CacheLocation = #"C:\Users\xxx\Desktop\"; to specify the cache location.
Just copy the cache to different machine under the same directory will work.
To cache the map data, check my github https://github.com/williamwdu/GMap.NETChacher
The cache directory will look like this TileDBv5\en\Data.gmdb
Pay attention that the Provider of the MAP that you have downloaded be the same provider that you have used in your code.
eq: GMap.NET.MapProviders.GMapProviders.OpenStreetMap

How can i view the live stream i'm publishing via expression encoder SDK on wpf from another computer?

So i have a lack of knowledge issue with this.
I'm currently streaming my webcam and trying to do a small conferencing application on WPF. I can easily see the streamed video by doing <MediaElement Name="VideoControl" Source="http://localhost:8080"/> on my computer.
But i don't know what to write instead of http://localhost:8080 on an external computer because of my lack of knowledge. I've tried to write my external ip address, i've tried to write my local network ip with a computer on the same network. None of them has worked.
To sum up, i need to know how to access my stream from anywhere around the world (wow that sounded extremely like IP).
Here is the code i wrote to broadcast my stream;
_job = new LiveJob();
EncoderDevice videoDev = null;
foreach (EncoderDevice ved in EncoderDevices.FindDevices(EncoderDeviceType.Video))
if (ved.Name == VideoDevices.SelectedItem.ToString())
videoDev = ved;
EncoderDevice audioDev = null;
foreach (EncoderDevice aed in EncoderDevices.FindDevices(EncoderDeviceType.Audio))
if (aed.Name == AudioDevices.SelectedItem.ToString())
audioDev = aed;
// preset, editting etc..
_job.ApplyPreset(LivePresets.VC1HighSpeedBroadband16x9);
LiveDeviceSource deviceSource = _job.AddDeviceSource(videoDev, audioDev);
_job.ActivateSource(deviceSource);
PullBroadcastPublishFormat outputFormat = new PullBroadcastPublishFormat();
outputFormat.BroadcastPort = 8080;
outputFormat.MaximumNumberOfConnections = 10;
_job.PublishFormats.Add(outputFormat);
_job.StartEncoding();
I'm sorry for my bad explanation, Thanks for the help!
Noone ever answered this?
Did you ever get it to work? If you could not open the stream from another computer in your LAN with VLC player, I would think your firewall is the blocker.
Allways when having issues with networking, turn off EVERYTHING so your stuff works, then turn back one and one. That way you get to find out which firewall/setting that is blocking you.
Once you get it to work in LAN, try from a machine outside your home network. Not all routers/modems support rerouting you back into your network if you try to access the external IP of your modem/router from inside your LAN. Your external IP can be found at whatismyip.com or similar sites.
So you will probably have to rely on help from someone else or try out some VPN solution to test conenction to your external address from outside your network.

Jabber-net integration

I'd like to ask your help regarding having a Google Talk Bot that will communicate with my code on my server.
I have downloaded Jabber-Net from code.google.com, but the examples there are not enough... I am new to these technologies, and have no clue about:
How will client arrive to my server? where should I change [if any] DNS to my server?
Which server side library should I use?
From the examples I understood that I need to have a Desktop-app running in the background constantly, which doesn't make sense to me.
Does anyone has an example of some better references to understand this better?
[Sorry for my ignorance...]
I'm not sure if I understand what you ask correctly. If you're asking how to connect to chosen server, console sample shows how to do it simply, you basically fill out JID class.
Sample from Jabber-Net
JabberClient jc = new JabberClient();
JID j = new JID(jid);
jc.User = j.User;
jc.Server = j.Server;
jc.NetworkHost = networkHost;
jc.Port = port;
jc.Resource = "Jabber.Net Console Client";
jc.Password = pass;
jc.AutoStartTLS = TLS;
jc.AutoPresence = initialPresence;
If you want to create your own server, there's a library (also running under .NET) called agsxmpp, it allows to create both, server and client, it's open source on MIT/GPL license afair. I don't know if jabber-net enables this feature. On the other hand, there are plenty of free jabber-server if you don't want to just use one of "public" ones, so it may be worth to consider just using something that is ready to be launched.
There's a console sample in the project, you don't need desktop-app (if this is what you were asking?), so you can write service, console app or anything else.
Here's a recent post that shows an example of replying to incoming messages on Gtalk using .NET

Categories

Resources