Could not open Google Drive app from work profile - ActivityNotFoundException

682 Views Asked by At

I am developing an Android application where, in some places, I need to open the Google Drive application by passing a specific URI. I have not encountered any problems doing this on a standard Google account. The problem is with corporate accounts.

Let me explain:

I have an Android tablet where I have configured 2 Google profiles, the NUMBER1 profile (the standard one) and the NUMBER2 profile (the company one). I have installed the Android application I am developing and the Google Drive application on both profiles. When I use the application installed on the NUMBER1 profile, I can open the Google Drive application from code, instead when I perform the same steps BUT using the NUMBER2 profile, then it returns me an exception due to the fact that it does not find any application to open with the package com.google.android.apps.docs.

I am attaching the code:

public static void openGoogleDrive(String uri, Context context, View view) {
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        intent.setPackage("com.google.android.apps.docs");
        context.startActivity(intent);
    } catch (ActivityNotFoundException exception) {
        Utils.buildInfoSnackbar(
            view,
            context,
            context.getResources().getString(R.string.no_app_found),
            Snackbar.LENGTH_LONG)
        .show();
    }
}

I connected in debug with the app on the NUMBER2 profile but it just returns an exception (ActivityNotFoundException). On the "logcat" I don't get any errors or warnings of any kind.

What do you think it could be? Could it be a GSuite side setting on the corporate account that doesn't allow opening other apps?

1

There are 1 best solutions below

0
PatrickdC On

Third Party Apps May Have Been Restricted in your Google Workspace

Super administrators of your Google Workspace can set which apps may or may not have access to your Google workspace. If you are not a super administrator in your Google workspace, I suggest contacting one so that you may discuss the permissions to be given to your app. If you are a super administrator, you may read the article Control which third-party & internal apps access Google Workspace data for details on how to give permission to third party apps.