Category: Xamarin

2020.09.01.

Xamarin.Android – Using SVG Images, VectorDrawable

By default, Android does not support svg. For this, they invented VectorDrawable, which can display svgs. First step: create a Xamarin.Android Project. Go to Main.xml and paste this: Yes, we will use VestorDrawable as a normal Image (png). After that we have to create a VectorDrawable. Create a svg image. And download it. Paste this svg file to: http://inloop.github.io/svg2android/. Download this xml and paste this […]

2020.09.01.

Xamarin.Forms – Using MQTT and Azure IoT Hub

If you have an Azure IoT Hub, you may also need a mobile app. You can communicate with Azure IoT Hub just like a regular MQTT. First step: create a Xamarin.Forms application (but very important, you can use this snippet in any native project, just copy this to the platform’s project). Right click on the Standard Library and click on Manage NuGet Packages. Add the […]

2020.09.01.

Xamarin.Forms – Mock Locations

This Project you can find at: https://github.com/officialdoniald/Xamarin.Forms.MockLocation. Download my NuGet Package: NuGet Gallery | Xamarin.MockLocationPlugin 1.0.0 Android: First, we have to request permissions in the Manifest and in the MainActivity (Runtime). Manifest: https://github.com/officialdoniald/Xamarin.Forms.MockLocation/blob/master/Xamarin.Forms.MockLocation.Mobile/Xamarin.Forms.MockLocation.Mobile.Android/Properties/AndroidManifest.xml MainActivity: https://github.com/officialdoniald/Xamarin.Forms.MockLocation/blob/master/Xamarin.Forms.MockLocation.Mobile/Xamarin.Forms.MockLocation.Mobile.Android/MainActivity.cs Sending mock lockation from Standard Library: DependencyService.Get().SendMockLocation(new IMockLocationPlugin.MockPosition() { Longitude = 24.234234, Latitude = 46.3213123, Accuracy = 1.0f, Altitude = 15, Bearing = 5f, Speed = 50f }); Deploy your […]

2020.09.01.

Xamarin.Forms Twilio implementation

This project you can find at: https://github.com/officialdoniald/Xamarin.Forms.Twilio Twilio created just for Android and iOS libs and not for Xamarin. So we need to create Bindings for Xamarin.Forms and native. First step: we need to create Android Binding Library(https://github.com/officialdoniald/Xamarin.Forms.Twilio/tree/master/Xamarin.Forms.Twilio.PoC/Xamarin.Android.Twilio.Client) and iOS Binding Library(https://github.com/officialdoniald/Xamarin.Forms.Twilio/tree/master/Xamarin.Forms.Twilio.PoC/Xamarin.iOS.Twilio.Client) in an Emptys Solution. We have to add the .aar/.jar file(to Jars folder to Android) and .a files (as native reference to iOS) […]

2020.09.01.

Xamarin.Forms send and receive SMS

This project you can find it at: https://github.com/officialdoniald/Xamarin.Forms.SendAndReceiveSMS We can easily send SMS from various platforms, but we can’t read SMSs so easily. Android: Receive SMS: In Android we can send and receive/read SMSs with just few line of code. We have to implement a BroadcastReceiver and gain permission in the AndroidManifest.xml. 1. AndroidManifest.xml(https://github.com/officialdoniald/Xamarin.Forms.SendAndReceiveSMS/blob/master/SendAndReceiveSMS/SendAndReceiveSMS.Android/Properties/AndroidManifest.xml): We have to gain permission to RECEIVE_SMS, READ_SMS, SEND_SMS and WRITE_SMS. […]

2020.09.01.

Xamarin.Forms using Mqtt

We can using of course mqtt in Xamarin.Form via dependency service / Xamarin.Forms.MessagingCenter, event or simply create a class instance. We are following the last option. First step, we need to install the MQTTnet NuGet Package for the Solution. (So in each project.) .NET Standard Library: We need to create an MqttClientRepository class in the .NET Standard Library. Next step the platform specific implementations. Android: […]

2020.09.01.

Xamarin.Forms Runtime Permission Handling above Android 6.0

After Android 6.0, we have to using Runtime Persmissions. No more enaugth to create an Android.Manifest file. How can we correctly use it? Step 1: Android.Manifest file Still we have to create an Android.Manifest file, but a little bit otherwise. We have to use this way: https://developer.android.com/training/permissions/requesting#java. So, if we have used it so far as “uses-permission” before, from now we have to use it […]

2020.09.01.

Xamarin.Forms save and open PDF file

This project you can find at: https://github.com/officialdoniald/Xamarin.Forms.Save.Open.PDF. It could be a real situation that your app need to save or open a pdf file. How can it possible? Throught DependencyService. There are many companies, who deal with generationg PDF Document in Xamarin.Forms. We need to create a PDF Document first and than save it. But if you want to open an exists document, just read […]

2020.09.01.

Xamarin.Forms get user location when it change

This project you can find at: https://github.com/officialdoniald/Xamarin.Forms.DetectUserLocationCange When you need to update the user’s location when it change you can make it in Xamarin.Forms too via DependencyService or using Xamarin.Essentials and create a Timer and get the actual Location per seconds (don’t do that :D). Before coding, we have to satisfy the users permissons. Andorid: (https://github.com/officialdoniald/Xamarin.Forms.DetectUserLocationCange/blob/master/Xamarin.Forms.DetectUserLocationCange/Xamarin.Forms.DetectUserLocationCange.Android/Properties/AndroidManifest.xml) Turn ACCESS_COARSE_LOCATION on. iOS: (https://github.com/officialdoniald/Xamarin.Forms.DetectUserLocationCange/blob/master/Xamarin.Forms.DetectUserLocationCange/Xamarin.Forms.DetectUserLocationCange.iOS/Info.plist) ATTENTION: if you will […]

2020.09.01.

Xamarin.Forms change ListView SelectedItemColor

This project you can find at: https://github.com/officialdoniald/Xamarin.Forms.ChangeListviewSelectedColor We have to create a Custom Renderer for a ViewCell. So let’s create a class in the .NET Standard,/PCL Project: https://github.com/officialdoniald/Xamarin.Forms.ChangeListviewSelectedColor/tree/master/Xamarin.Forms.ChangeLvSelectedColor/Xamarin.Forms.ChangeLvSelectedColor/CustomControl/ListViewCustomViewCell.cs/ We created a property for the SelectedItem’s color. Don’t forget: this enum is a cutom enum, we have to create it: https://github.com/officialdoniald/Xamarin.Forms.ChangeListviewSelectedColor/blob/master/Xamarin.Forms.ChangeLvSelectedColor/Xamarin.Forms.ChangeLvSelectedColor/Helper/Enums.cs Let’s create the platform specific code. Android: we have to change the Android’s Theme at […]