I have a Xamarin.Forms solution and am finding it difficult to implement the Intent class as this library is part of Android.Content.
My solution has 2 projects. Project1 & Project1.Android.
I cannot seem to use the following in my Project1 project:
using Android.Content; using Android.App;
Am I missing something here? Any help is greatly appreciated.
I need to use Intent to broadcast a message to another app on the Android device.
using Android.Content; using Android.App;
Since your app is a Xamarin.Form app, you cannot invoke code from android platform directly. But you can use
DependencyServiceto invoke android platform code from shared code. The DependencyService class is a service locator that enables Xamarin.Forms applications to invoke native platform functionality from shared code.From official document Xamarin.Forms DependencyService, we could know that the process for using the
DependencyServiceto invoke native platform functionality is to:For more information, please check document: Xamarin.Forms DependencyService.
And there is an official sample about this, you can check it here: Dependency Service