#StackBounty: #android #google-drive-api #android-download-manager Download Manager with Google Drive URL

Bounty: 100

I’m trying to download a file stored in Google Drive using android DownloadManager.

I get the sign in token from Google like following:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)

I receive a notification with google drive file url and i pass it to the DownloadManager, passing to it the token:

String cookie = CookieManager.getInstance().getCookie(d.getURL());
            request.addRequestHeader("Authorization", "OAuth " + profile.getToken());
//d is the document object, that contains url, file name, etcc
//Profile is a simple object class that hold the user data taken from sign Google, like token, name, email, etcc

Using a simple Broadcast Receiver to manage the download result (ACTION_DOWNLOAD_COMPLETE).

The download is done successfully, but the file is corrupted.
If i try to open it, the device (and pc) gives me a format error.

(The account that i’m using is enabled to read and dwonload the document form this specific drive storage)

Is this the correct way to download a Google Drive file using DownloadManager? Is it possible to do that?

Get this bounty!!!

#StackBounty: #java #android #shortcut #android-download-manager Android: Remove Downloaded file shortcut from "Downloads" fo…

Bounty: 50

In my code I used to download apk, use it and then remove it. But after removing it, Apk is removed only from internal storage (internal storage/android/data//files/download) but it still is in My Files/Downloads folder.
How can I remove this shortcut/view from My Files/Downloads folder programmatically, or how to prevent saving it into this folder?

Downloading code:

final String destination = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) + FORWARD_SLASH + TMP_APK_NAME;
final Uri uri = Uri.parse("file://" + destination);

//set downloadmanager
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

//set destination

// get download service and enqueue file
final DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);

Deletion code:

//Delete update file if exists
final File file = new File(destination);
if (file.exists()) {

Get this bounty!!!