When I open webview in external browser, Whitelabel error is occour. How can I fix?
How to fix Whitelabel error page when open webview in external browser?
Project using Webview in Android works perfect. When I test in IOS the webiew show blank screen
Hi everyone,
I am very novice in Xamarin. I made a simple app that has a webview. The project runs perfect in android, I mean, the activity indicator show and hide when the webview loads the url and off course the webview show the content of my page. Now I am trying to run the same project in IOS, but the app shows the activity indicator, the it hides but I dont see the content in the webview, I mean, I get a blank page after the activiry indicator dissapear. I commented the e.cancel = true in webonnavigated method but I did not work. This app is very simple, but what little it has programmed cost me blood, sweat and tears because I really don't handle Xamarin well. Please if you can help me see why this does not work on IOS I would greatly appreciate it. I attached mainpage.xaml and the code behind.
Thanks for the help!!!!!!!
How can I force a view to re-render, redraw, rebind?
The reason is because something in the viewmodel changes that requires the entire view to clear its contents and redraw all over.
I cannot use "notifyPropertyChanged" in this instance as it is more sophisticated than that.
I've tried "InvalidateLayout()", "InvalidateMeasure()", "ForceLayout()", "UpdateChildrenLayout()" and nothing works!
I need to be able to say "view.ReRender()" and it just clears everything out and initializes all over again. You would think something like this would be easy!
is there a Tabbed view in Xamarin.forms?
Hello,
any idea how to make a Tabbed view in xamarin.forms,
i only found Tabbed page which is not possible to put it inside a content page!
choosing Xamarin.forms is bad choice? should i've used each platforme beside with xamarin.android and xamarin.ios!
Thanks in advance
Xamarin Essentials - Geolocation. Always on permission on Android doesn't work anymore
After updating the Xamarin libraries in my xamarin forms app and setting the Android target framework from 8.0 to 10.0, the app on Android is no longer requesting Always On location when calling the geolocation code below:
var location = await Geolocation.GetLocationAsync(new GeolocationRequest(GeolocationAccuracy.Best, TimeSpan.FromSeconds(10)));
The app only shows the "When app is in use" and "Deny access" option now and no longer the "Always On" option.
I tried adding a new flag permission flag to the android manifest file but no result:
Anyone knows how to solve this and bring back the always on for android devices?
MainActivity, CurrentActivity, New Activity in Xamarin.forms
In Xamarin.forms on Android we do many things on MainActivity or CurrentActivity instead of creating a new activity. For example, you want to log in with google, when I check java or kotlin even on xamarin.android implementations, they start a new AppCombatActivity but Xamarin.Forms samples or answers usually using MainActivity as currentcontext or using plugins like CurrentActivity. Why is it? is it because Xamarin.forms is build on Mainactivity? Is there any pros or cons starting a new activity for log in purpose or in general?
Click Button represents SelectedItem command from ListItem
Hi buddy,
I made 1 button and 1 group of list items. then I choose one from the list of items. how to make this button can represent the command select goods when the button is pressed. assuming as if the select item command was executed on the button.
thanks in advance for the answers given
How to show DisplayAlert when app go to background?
Hi, I have an app, that monitoring your BPM (and other stuff) and if your BPM is over range, you will receive DisplayAlert. You can close this alert for example 2 times, after third attemp this app will send warning sms. This works very well when this app is running on screen. When screen is black or you press home button, this app stil monitoring your BPM but show DisplayAlert only when you open this app.
Is possible to show DisplayAlert to person, when display is off or client is somewhere else?
I dont know If I need use somehow this OnSleep method? But I am really dont know, how to use it, because all the magic is on MainPage.cs. And also I dont know what for is OnStart method. When I open my app, this public App() will "start" my app. I dont need use OnStart() method.. ?
public App() { InitializeComponent(); MainPage = new Pulsometer.MainPage(); } protected override void OnStart() { // Handle when your app starts } protected override void OnSleep() { // Handle when your app sleeps MessagingCenter.Send<Application>(this, "sleep"); } protected override void OnResume() { // Handle when your app resumes }
And this is MainPage.cs function, that every 1second checking BPM and if your rate is below or over the range, this will show you DisplayAlert od send sms.
private void OnMonitorDataUpdated(object sender, HeartRateMonitorDataUpdatedEventArgs e) { // update displayed value hrValue.Text = e.HeartRate > 0 ? e.HeartRate.ToString() : "0"; // get ranges var rangeMax = Preferences.Get("my_max", "150"); var rangeMin = Preferences.Get("my_min", "50"); var sms_number = GetSMSNumber(); var attemptMax = Preferences.Get("attempts_value", "3"); if (e.HeartRate > int.Parse(rangeMax)) { if(counter < int.Parse(attemptMax)) { // notification counter++; DisplayAlert("Notice", "BPM is over limit" + counter + "/" + attemptMax, "OK"); StopMeasurement(); } else { // send sms SettingsPage.SendSms(sms_number); DisplayAlert("Notice", "sending sms ... ", "OK"); StopMeasurement(); } }
Simply - I need to, that my app is still working, when screen is black or when I click home button and go somewhere else. For example I have my watch on my hand, doing some stuff, screen is black... but my BPM is over some limit, so this app should show on display some warning (or send sms)
Xamarin fails to Archive the project for publication (iOS)
Hello everyone,
I developed a multi-platform, it builds without any error and few warning. It runs on the device in debug mode. When I set it to Release mode and trying to archive it for publication, it throws a few warning that stops the archive.
It never happened previously that warnings crash the archive processing.
these are the warnings:
*** Found conflicts between different versions of "SQLitePCLRaw.batteries_v2" that could not be resolved.
- Found conflicts between different versions of "SQLitePCLRaw.core" that could not be resolved.
- Found conflicts between different versions of "System.Net.Http" that could not be resolved.
- Found conflicts between different versions of "Microsoft.CSharp" that could not be resolved.
- Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file.
- Obsolete member 'AppDelegate.FinishedLaunching(UIApplication, NSDictionary)' overrides non-obsolete member 'UIApplicationDelegate.FinishedLaunching(UIApplication, NSDictionary)'**
How can I archive the app? Do you have any thought?
Kind regards,
Kamal
Xamarin Forms Templets
Hello Guys
from Where can i Purchase Food APP Templates in Xamarin forms ?
Thanks
trim cut audio file
hello guys i need to cut mp3 files from second (10) to second (30)
i can't find anything anyone can help me?
i found something like ffmpeg but don't know how it works really?
Trying to implement Ads in a Forms project (Android for now, iOS down the road)
I'm trying to implement ads in my app, and eventually in-app purchases (to register a full version upgrade from free)
I've been following the tutorial from this site
https://www.c-sharpcorner.com/article/google-admob-display-ads-in-xamarin-forms/
I've created my AdMob Account, and added my app, I have the adUnitID, and from what I can tell that part is completed properly.
The problem I am having is when I try to compile the code, I get missing AndroidX assemblies,
Here is the specific error I am getting
Could not find 8 Android X assemblies, make sure to install the following NuGet packages: - Xamarin.AndroidX.Lifecycle.LiveData - Xamarin.Google.Android.Material - Xamarin.AndroidX.Legacy.Support.V4
(Please note it says 8 but only lists 3 assemblies)
I've tried installing those assemblies. Once they are installed I get two errors when I try to build.
one is 1>C:\Users\jesse\OneDrive\Documents\Source\...\obj\Debug\90\lp\124\jl\res\values\values.xml(1778): error APT2000: expected enum but got (raw string) slide.
Which is this line in the code
<item name="animationMode">slide</item>
And the other error is 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(164,3): error APT2062: failed linking references.
This is the linking reference it refers to.
<Aapt2Link Condition=" '$(_AndroidResourceDesignerFile)' != '' And '$(_AndroidUseAapt2)' == 'True' " ContinueOnError="$(DesignTimeBuild)" DaemonMaxInstanceCount="$(Aapt2DaemonMaxInstanceCount)" DaemonKeepInDomain="$(_Aapt2DaemonKeepInDomain)" ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)" AssemblyIdentityMapFile="$(_AndroidLibrayProjectAssemblyMapFile)" ImportsDirectory="$(_LibraryProjectImportsDirectoryName)" UseShortFileNames="$(UseShortFileNames)" OutputImportDirectory="$(_AndroidLibrayProjectIntermediatePath)" OutputFile="$(ResgenTemporaryDirectory)\resources.apk" PackageName="$(_AndroidPackage)" ApplicationName="$(_AndroidPackage)" JavaPlatformJarPath="$(JavaPlatformJarPath)" JavaDesignerOutputDirectory="$(ResgenTemporaryDirectory)" CompiledResourceFlatFiles="@(_CompiledFlatFiles)" ManifestFiles="$(ResgenTemporaryDirectory)\AndroidManifest.xml" AdditionalAndroidResourcePaths="@(_LibraryResourceDirectories)" YieldDuringToolExecution="$(YieldDuringToolExecution)" ResourceSymbolsTextFile="$(IntermediateOutputPath)R.txt" ResourceDirectories="$(MonoAndroidResDirIntermediate)" ExtraArgs="$(AndroidAapt2LinkExtraArgs)" ToolPath="$(Aapt2ToolPath)" ToolExe="$(Aapt2ToolExe)" UncompressedFileExtensions="$(AndroidStoreUncompressedFileExtensions)" ProguardRuleOutput="$(_Aapt2ProguardRules)" />
If I change the SDK version to Android10, all of the errors go away, the package gets deployed, but will not show up in the app launcher, and will not start when I try to debug it.
I'm terrified at what it's going to be like to add the in app purchase for my app... (actually just considering making a separate app in the store and making a new build target / alternate code base to build it from)
Please, there has to be some way to implement ads in a Xamarin.Forms app, that supports Android 9...
Anyone who's implemented AdMob to a Xamarin.Forms app (I don't even care if it supports iOS for now. I would be nice for the future, but for now I just want to get my Android app up and running)
Please help!?
Need some feedback please!
I am working on making a free version of my app. To do this I need to implement ads in the app, but want to make this as seamless as possible to my existing code.
I will just create a new build target for a _Free
version. I can then use this code to build both versions of the app.
When I track the number of times the user viewed a reward video, I understand you can use FireBase
to track these things, but I was considering tracking the number of times as a field in the database using cryptography for that record entry. This way the database will always know how many rewards the user gets.
I am trying to keep this app as off the cloud as possible.
Would this be a good approach? or is there a nifferent way I should be doing this?
I have started working on this implementation, but would like to hear people's feedback on if this sounds sound for how to go about it. I am using the MarcTron.AdMob
library. This library is incredibly simple and easy to implement so if you're not familiar with it's API, that shouldn't matter.
My BaseViewModel
implements the AdDataViewModel
as a public element within it. This means any viewmodel I derrive from the base will automatically have access to creating ads on their pages.
somepage.xaml
...... <Stacklayout Orientation="Vertical"> <Frame x:Name="myAdview" /> ..... other page elements .... </Stacklayout>
Then in codebehind all I have to do is this.
Somepage.Xaml.cs
public MyPageViewModel viewModel; public void InitializationRoutine() { //viewmodel has been initialized in the page constructor ...... viewModel.AdDataViewModel = new AdDataViewModel(); myAdview.Content = viewModel.AdDataViewModel.AdViewElement; ...... }
The viewmodel then creates / sets the data for this particular implementation of the ad view;
I am in the process of extending this viewmodel to support reward ads IDs and handlers independently of banner ads all in the same instance (basically user has option to view add for reward within the app)
namespace MyApp.ViewModels { //EventParent overloads the SetProperty and OnPropertyChanged events for my getters and setters public class AdDataViewModel : EventParent { //Lazy constructor, have class do everything public AdDataViewModel() { Type = AdType.Banner; Initialize(true); } //set a key as a part of the constructor public AdDataViewModel(string key) { Type = AdType.Banner; Initialize(true); } // set both key and type public AdDataViewModel(string key, AdType type) { Type = type; AdIDKey = key; Initialize(false); } //This is an enum of various ad types public AdType Type; /************************************************************** All of the get / set sets use this methodology, I've trimmed them for space and readability ***************************************************************/ private string adIDKey; public string AdIDKey { get => adIDKey; set { SetProperty(ref adIDKey, value, nameof(AdIDKey)); OnPropertyChanged(nameof(AdIDKey)); } } //This is the actual contentView for the ad private MTAdView adViewElement; public MTAdView AdViewElement { .... get set as before... } private string adName; public string AdName { .... get set as before... } private bool personalizedSetting; public bool PersonalizedSetting { .... get set as before... } private int adHeight; private int adWidth; //If we already have a key the user can make this call skip calling // Alternately this can be called to change the AdIDKey private async void Initialize(bool NeedsKey = true) { //Specify default values for height and width. adHeight = 80; adWidth = 120; if (NeedsKey) AdIDKey = await GetAdKey(Type); // This can be changed later, but is defaulted here. PersonalizedSetting = true; AdViewElement = new MTAdView(); RefreshAdData(); } public void RefreshAdData() { AdViewElement.AdsIdKey = AdIDKey; AdViewElement.PersonalizedAds = PersonalizedSetting; AdViewElement.HeightRequest = adHeight; AdViewElement.WidthRequest = adWidth; } //This is where I need the most help. //Is this a good way to go about getting the keys for my ads? I want to make // debugging and free vs paid versions use as much common code as possible. private async Task<string> GetAdKey(AdType type) { string szKeyType = string.Empty; switch (type) { case AdType.Banner: //Default to NOKEY, change it if we are in the appropriate build szKeyType = "NOKEY"; //These are arbitrary, I can overload them to have getters and setters, // or just leave them statically coded like this. adHeight = 80; adWidth = 120; #if DEBUG AdIDKey = "ca-app-pub-3940256099942544/6300978111"; #elif _Free //We're in the free version of the app, so we can get the key szKeyType = "BannerAdKey"; #endif //Commercial version of the app will still pass through the NOKEY so there will // be no wasted overhead for getting the key from securestore. break; /********************************************************* This has case statements for all of the supported ad types *********************************************************/ } //If the 'NOKEY'was set, this is a test build and the key has been set to the test key if (!szKeyType.Contains("NOKEY")) AdIDKey = await SecureStorage.GetAsync(szKeyType); //Return the appropriate key. return AdIDKey; } } }
I have another question about making my free vs paid versions use common code bases. But I will post that a little later.
Any feedback would be GREATLY appreciated!
Cheers!
Zebra TC56 Keep Reinit every couple Scan EMDK or DAtaWedge
Today, i created a simple inventory transfer location app in VS2019 with Xamarin forms (4.8Version), which it will be used in a Zebra TC56 Nougat, it is just one screen with couple of labels (Location to transfer, Serial to transfer, Item Code of serial, description of the item and the Qty of object ) the user scan the barcode of the location to transfer the material, and the serial, both using the Zebra barcode reader (Try both EMDK --4.0 and 6.0-- and Datawedge), the first is the location, it is get on the Android (EMDK) and send to the Xamarin using the messagingcenter, if the barcode start with 1L we remove the 1L and assign the remaining to the location label (We don't want user type it). then the user will start scanning the serials of the items to transfer, in here if the scanned data start with "S" it sent to our DB to retrieve the data of the serial through a web service, using the HTTPClient Post. the information is retrieved the data is assigned to the labels ItemCode, Description, and Qty, if the current location of the object is not the recently scanned location it call another web service passing the new location and the serial.
The app works, but after some scanning the app re-init (On-Create() Android runs again), i observe this on the Debug mode (Hook the TC56 to the computer, i put a stop on the call to the Enable of the Barcode reader, and see that the debug stop again on this section) and also on release mode (The App has a counter of how many serials has been transfer, but when the app re-init all labels get blank and the counter show 0).
I don't have any clue about what is causing the app to re-init, all functions have Try-Catch.
Xamarin Hot Restart stuck on iTunes detection
Xamarin Hot Restart is only able to detect iTunes when it is downloaded from the Microsoft Store and not when it’s downloaded from Apple’s website.
When using iTunes from Apple’s website, the Visual Studio console repeatedly outputs: Apple Support - iTunes installed: ‘False’, Installation type: ‘Msi’
Is there any way to manually set where Visual Studio is checking to detect the iTunes installation?
Xamarin Exo Player Equilizer settings
How to enable equiliser settings into xamarin audio exoplayer.
how to use expander ? I have follow as per docs but getting exception
This is the exception while adding expander even i have added Forms.SetFlags("Expander_Experimental") .The error below as follows
"The class, property, or method you are attempting to use ('Expander') is part of Expander; to use it, you must opt-in by calling Forms.SetFlags("Expander_Experimental") before calling Forms.Init().'"
Upload files via web api, the files are sent as byte[]
I'm trying to upload files via web api, the files are sent as byte[].
I manage to upload only one file per request, but if I select multiple files it only upload one file.
This is the client side code:
var content = new MultipartFormDataContent(); ByteArrayContent byteContent = new ByteArrayContent(_mediaFile); content.Add(byteContent, "file", _mediaFIleName); var httpClient = new HttpClient(); var uploadServiceBaseAddress = "http://localhost:1000/api/home/Upload"; var httpResponseMessage = httpClient.PostAsync(uploadServiceBaseAddress, content);
This is the server side code:
var httpRequest = HttpContext.Current.Request; foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; var filePath = HttpContext.Current.Server.MapPath("~/uploads" + postedFile.FileName); postedFile.SaveAs(filePath); }
Is there another method to do this or am I doing something wrong here in the code above?
Is it possible to open html file with external browser?
I want to open html file in external browser from my app.
Is it possible? How can I do?
Xamarin forms Exoplayer set proper pitch.
I am using Exoplayer for for playing audio into my xamarin forms app. I added pitch value -12 to +12 .But 0 and its less value not working , throwing error. Only higher value of 0 is working. Can anyone tell me how to support negative value as a pitch in exoplayer