Xamarin.Forms: Android app forgets the style when using DynamicResource

This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.If you break the look and feel of the app when you switch apps on mobile, and you use styles as DynamicResources, which you add as MergedDictionaries in App.Xaml,you should pay attention to this: When you don’t exit the Android app, but bring it back to the foreground after a very long time, the constructor logic in App.xaml.cs runs again. Don’t forget to add MergedDictionary from code, which contains the styles. If you forget this, all controls will appear in the app with their default look. I wrote about how to handle restarting the application here: https://www.banditoth.hu/2021/03/22/xamarin-forms-reopening-application-best-pratices/

Xamarin.Android get resource id without ResourceManager.

This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.If calling ResourceManager.GetResource(“resourceName”) doesn’t work because the framework doesn’t return the resource you want, you can bypass it with the following code snippet: I used this code snippet to set a custom push notification sound

Xamarin Forms: White screen between page push and pop solved

This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.If you are experiencing white screen when pushing to Navigation or Modal stack on Android, read on. I’m not sure is this a bug in Xamarin Forms or not, but I guess this is, because it comes only in certain scenarios, and not always. What is happening, how do you notice this error? You have got a NavigationPage. You are pushing a new page to the navigationstack, and the page is not getting rendered, only a blank white screen displays. If you are rotating the device, the page is getting rendered well. My environment was:Xamarin.Forms: 4.8 up to 5.0Device: Samsung Galaxy A12Visual Studio 2019 Professional with Xamarin.Android SDK 11.4.0.5 Solution Always invoke the INavigation’s methods on the applications Main Thread. UI changes must go always on the UI thread of the application. Create a class which wraps the INavigation presented by your Views. It’s handy to store a reference in this class to the Applications Current MainPage’s INavigation instance, so try to build your code to supply the actual INavigation Instance every time to this class when the application’s mainpage is set. Remarks Consider a check for the current thread in the methods body. If they are being executed in the main thread, you won’t need to switch to the main again. Bug is reported on Github: https://github.com/xamarin/Xamarin.Forms/issues/11993

Complete CI/CD tutorial for Xamarin Android with Google Play publish in Azure DevOps | Part 2.

This content has 4 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.If you haven’t seen part 1, click here, and start build up your CI/CD pipeline now. Part 2 Contains: Configuring build with creating signed APK, and making artifacts from it Setting up branch policy to master Configure some magic Let’s go back to Pipelines. Edit your previously created pipeline by clicking the three dot on the pipelines row. CI is based on cloud machines hosted somewhere over the world. This computers called as agents. They are used to follow your instructions, defined in the yml file. The base Xamarin.Android yml is only to build your code. But we will make some additional steps in order to create a signed APK of every build. Follow up, to complete this setup. Recommended branching strategy for this is to keep a development branch, and pull request your feature branches to it, and finally pull request the development branch to the master, and keep your master is always at your production version. The figure below shows visually this method. Source: https://dzone.com/articles/feature-branching-using-feature-flags-1 Create a signed APK or bundle from every build First, set up some variables for this pipeline. You will find a Variables button on the right top of the tab. Click on it. Let’s add a new variable by clicking the “New variable” button. We will need 4 vars. Remember, that i told…

Complete CI/CD tutorial for Xamarin Android with Google Play publish in Azure DevOps | Part 1.

This content has 4 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.This tutorial will drive you through setting up a great CI/CD pipeline for Xamarin Android in a fully hosted Azure DevOps enviroment. Part 1 contains: Creating an empty Xamarin.Android build pipeline Uploading keystore file to secure files Start with some code I have added some basic code to my demo repository. It is a boilerplate Xamarin Application, with no additional customized code. If you have code in your repo, make sure it builds successfully. Create your first pipeline On the left side menu, go to Pipelines/Pipelines. This menu will show up a welcome page, to create new pipeline. Click on ‘Create Pipeline’ button, or if you have already created your first pipeline, find a button to add a new one. On the next page, a wizard will guide you through the basic setup. If you have your code in Azure Repos, click the button for that. Select your repository where your Xamarin Android code lives. On the next page, you can select a template to create your pipeline yml. Let’s choose Xamarin.Android. If you want, you can rename your yml file. Pipeline files will be placed in your repository root by default. YML file extension stands for YAML files. Review your newly created file, how it looks like. Luckily, you do not have to write yaml too much, but good…