Get Android Context in PCL project

后端 未结 2 1510
故里飘歌
故里飘歌 2021-02-20 06:54

How do I get the Android context from the Xamarin.Forms PCL project?

I have tried to search stackoverflow but none fit my search.

I am new to Xamarin.Forms and I

相关标签:
2条回答
  • 2021-02-20 07:28

    You can access in android project with:

    Xamarin.Forms.Forms.Context
    
    0 讨论(0)
  • 2021-02-20 07:32

    There is no knowledge about Android Context inside the PCL. You have Access to it only inside Android projects.

    If you want your app to behave differently based on the Context in Android applications then you need to abstract this logic by a platform independent interface and access it via a dependency injection container.

    I prefer to use the Mvx container shipped with MVVMCross. There is a great tutorial for Injection of Platform Specific Services.

    0 讨论(0)
提交回复
热议问题