In a mobile application I’m building with Xamarin Android I connect to an Azure Mobile Services backend. Xamarin made this easy by providing an Azure Mobile Services component.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Activity (Label = "RunningAssistant", MainLauncher = true)] | |
public class MainActivity : Activity | |
{ | |
int count = 1; | |
public static MobileServiceClient MobileService = new MobileServiceClient( | |
"https://mymobileservice.azure-mobile.net/", | |
"SharedKey" | |
); | |
protected override void OnCreate (Bundle bundle) | |
{ | |
base.OnCreate (bundle); | |
// Set our view from the "main" layout resource | |
SetContentView (Resource.Layout.Main); | |
// Get our button from the layout resource, | |
// and attach an event to it | |
Button button = FindViewById<Button> (Resource.Id.myButton); | |
button.Click += async delegate { | |
var table=MobileService.GetTable<Favorites>(); | |
await table.InsertAsync(new Favorites(){ | |
Hours = 2, | |
Minutes = 2, | |
Seconds = 1, | |
User="test" | |
}); | |
}; | |
} | |
} | |
} |
However when I tried to connect to Azure, every call failed with the following error message:
“The authentication or decryption has failed.”
I was able to fix the problem by switching to a more recent Android version in the emulator.