Xamarin Forms Android Error: Please install package ‘Android Support Library’

The error message tells you pretty explicitly what the error is C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\android_m2repository_r10.zip is not a valid zip file How to fix it Please download https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extract it to the C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\content directory.

How to make long press gesture in Xamarin Forms?

You can do it cross platform way by attaching the below behavior, as long as it is Xamarin.Forms.Button or a sub-type of it. using System; using System.Threading; using System.Windows.Input; using Xamarin.Forms; namespace App.Controls.Behaviors { public class LongPressBehavior : Behavior<Button> { private readonly object _syncObject = new object(); private const int Duration = 1000; //timer to … Read more

How to use Push Notifications in Xamarin Forms

I just implemented push notification a few days ago, and I’ll share my solution here (based on PushSharp) Step by step guide: 1) In your shared project, create an Interface called IPushNotificationRegister public interface IPushNotificationRegister { void ExtractTokenAndRegister(); } This interface is used for fetching the push token and then send it to the server. … Read more

How to keep keyboard on Xamarin.Forms?

Just to point out another solution for Android. In case you want to keep always visible the keyboard for a specific Editor Renderer, you need to override the following methods in the MainActivity class: private bool _lieAboutCurrentFocus; public override bool DispatchTouchEvent(MotionEvent ev) { var focused = CurrentFocus; bool customEntryRendererFocused = focused != null && focused.Parent … Read more

How to view PDF file using Xamarin Forms

Android: public void OpenPdf(string filePath) { Android.Net.Uri uri = Android.Net.Uri.Parse(“file:///” + filePath); Intent intent = new Intent(Intent.ActionView); intent.SetDataAndType(uri, “application/pdf”); intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask); try { Xamarin.Forms.Forms.Context.StartActivity(intent); } catch (Exception) { Toast.MakeText(Xamarin.Forms.Forms.Context, “No Application Available to View PDF”, ToastLength.Short).Show(); } } iOS, a bit more complex and requiries some extra classes: public void OpenPDF(string filePath) { FileInfo … Read more

Xamarin – Requesting camera permissions in WebView

Updated: In my previous answer, it shows how to add camera permission on webview. The link you provided, it works now. https://xamarin.swappsdev.net/ It seems to provide a camera preview function. It need to check permissions on API 23+. On Xamarin.Forms, you could use Permissions Plugin. https://github.com/jamesmontemagno/PermissionsPlugin First, add the camera permission in Android Manifest. Your … Read more

Accessing directly a Sql Server Database in Xamarin.Forms

You cannot access directly an sql server from your pcl project in Xamarin.Forms because System.Data.SqlClient is not available on pcl. But you can do it through a dependency service. First in you PCL project declare you service public interface IDbDataFetcher { string GetData(string conn); } Then on you Android project implement the service interface [assembly: … Read more