简体   繁体   中英

Is it possible to navigate between a Xamarin forms content page to an Android Activity?

I started a shared project and I'm building my app using xamarin forms.

When I was trying to use Xamarin Mobile reference I noticed that I might have to create an activity(in case of android) so I can call MediaPicker construtctor which needs an Android.Content.Context as argument.

As I said before I builded my app in a shared project using Xamarin forms and I'm navigating through content pages, how can I navigate between a content page to an Android Activity in my shared project? ( Don't even know if it is possible )

It is possible, but Xamarin Forms should not and cannot know about platform specific features like the concept of Activity and the way it is started.

This is where dependency services come in place.

Forms and Dependency Services

The main idea is to have an abstraction interface that Forms can use to execute platform specific implementations.

As soon as the Android application is started you register the implementation with the dependency service so that the .Forms library can then request the implementation to execute something...

This pattern is called Dependency Injection .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM