Search code examples
androidandroid-intentgoogle-drive-android-apiandroid-browser

How to open the url as Intent.ACTION_VIEW use only Google Drive?


open with option

I'm making an application to download theme for popular messenger in Korea. This app obviously needs the server to save theme files. I chose server as Google Drive cause of that its service is free and unlimited. When the user clicks on the download button, App's downloading theme from Google Drive public link. It's no problem if the URL open as Google Drive app. But it open URL with Samsung internet browser as above image. Google Drive Code example like this sentence, Like this drive.google.com/file/d/FileCode/view?usp=sharing.

I want to do that USERS OPEN THE URL WITH ONLY GOOGLE DRIVE.

public void setThemeDownloadButton(final Context context, final String url) {
    themeBottomDownload.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        }
    });
}

Solution

  • Set package for specific app

    intent.setPackage("com.google.android.apps.docs");