Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Pass data from Android Project to PCL

$
0
0

Hi, I need to take photo from a PCL project (only in Android at the moment). Tried to use XLabs but fail to use it. So I am trying to use native code and dependency service. So this is what I did and what I need to do:

  1. Create interface in PCL to implement from platform specific (done)
  2. In the PCL use the methods from the platform specific with dependency service (done)
  3. In the Android project implement the interface and use the native code to use the camera (done)
  4. In Android project detect when the user takes a photo (done)
  5. Notify the PLC project when a user takes a photo (todo)

To post some code, from point 4 I receive the OnActivityResult and there I detect if the user effectively took the photo. Now I need from there to notify the PCL project that the photo captured:

In Android project, MainActivity.cs

protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            // User canceled
            if (resultCode == Result.Canceled)
                return;
            if (resultCode == Result.Ok)
            {
                System.Diagnostics.Debug.WriteLine("OnActivityResult: Ok photo");
                // TODO: pass the photo to the PCL or notify the PCL so it goes and search the photo
            }
        }

I saw this thread were @adamkemp helped @AlessandroCaliaro that is something like what I need but I can't figured it out how to achieve what I need.

Thanks for any help in advance!


Viewing all articles
Browse latest Browse all 77050

Trending Articles