0

I have get the Android to load a file dialog for google drive after authorization. Now I have to do it on Xamarin Form but unable to find a file picker for google drive. Does google drive have a file picker for Xamarin Form.

public void RequestGoogleDrivePicker() {
        IntentSender intentSender = 
            Android.Gms.Drive.DriveClass.DriveApi.NewOpenFileActivityBuilder ()
                .SetMimeType (new string[] { "application/pdf" })
                .Build (GoogleApiClient);
        try { 
            StartIntentSenderForResult ( intentSender, GOOGLE_REQUESTING_OPENER_CODE, null, 0, 0, 0);
        } catch (Android.Content.IntentSender.SendIntentException e) {

        }
    }
LittleFunny
  • 8,155
  • 15
  • 87
  • 198

1 Answers1

0

Google Drive file browser dialog for Xamarin.Forms?

Short answer: No

Longer answer: Yes, but...

1) You either use the "native" platform Drive SDKs that contain pre-build file browser dialogs for Android and iOS and do this via a Forms' dependency service like you already started in the Xamarin.Android code in your question.

2) You skip the "native" mobile libraries, use the C# PCL-based Google Nugets in your Forms' project and build your own file dialog in Forms as there are no dialogs in these libraries as they are convenience wrappers for the Drive's REST API.

Nugets:

  • Google.Apis
  • Google.Apis.Auth

i.e. You can retrieve all the files in Drive, you would need to present these in a UI of your own design (Listview, ...), see link below for full sample:

IList<Google.Apis.Drive.v3.Data.File> files = listRequest.Execute().Files;
if (files != null && files.Count > 0)
{
    foreach (var file in files)
    {
        Console.WriteLine("{0} ({1})", file.Name, file.Id);
    }
}
else
{
    Console.WriteLine("No files found.");
}

Google Drive .NET Quickstart

SushiHangover
  • 73,120
  • 10
  • 106
  • 165