Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Call an Android Activity from PCL


I am relatively new to Xamarin.Forms and am currently working on a cross-platform app. Part of the app requires videos to be played using Brightcove's Player SDK (Java classes). I have created a Binding Project for this and am able to play videos on Android.

My views are created in the PCL of my app but the Brightcove SDK is native so I have developed an Android Activity to implement the Player. What I am now trying to do is find a way to run that Activity as part of one of my views, i.e. when someone clicks a particular button on the app the Activity will run and play a video as the top half of one of my PCL views.

I was just wondering if anyone has any guidance on the best way to do this? Any advice is appreciated.

Thanks very much,

Best Answer


  • StephenWillisStephenWillis Member ✭✭

    Thanks very much for the advice ClintStLaurent. So are you suggesting I create a custom view and create a custom renderer for the view in my two native projects? I've only started out on Xamarin recently and have used custom renderers but usually only for controls like entries and webviews.

    Just to give a bit more info - the control I'm trying to render is a BrightcoveVideoView which I generate in Android using a Brightcove Player Android SDK and in iOS using a Brightcove Player iOS SDK. I'm not sure which PCL control this would be custom rendered from, would it be a view?

  • salmanksalmank Member ✭✭

    Hi @StephenWillis , did you got any solution for this. I am also stuck on the same part. I am able to run it in Xamarin.Android project but not able to run it in the Forms project.

    Any suggestions would be appreciated.

  • Hi @salmank,
    Yes, with a fair bit of work I did get the SDK to work in Xamarin.Android. In my Android project, I was able to create a custom renderer with the attributes / signature:

    [assembly: ExportRenderer(typeof(FitchVideoView), typeof(CustomBrightcoveVideoView_Android))]
    namespace CustomRenderer.Android
    public class CustomBrightcoveVideoView_Android : WebViewRenderer


    In my PCL, I have a xaml file with:

    When the user clicks on the button for the video to play, the layout is replaced with the video view using the lines in the xaml.cs:

    var fitchVideoView = new FitchVideoView
    HeightRequest = videoHeight,
    HorizontalOptions = LayoutOptions.Fill,
    BindingContext = ModuleDetails


    I hope this is of help, I'm not sure if this covers the issue you're stuck on. If not let me know.

Sign In or Register to comment.