aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-06-08 03:50:34 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-06-08 03:50:34 +0000
commit4c762f4bd9a9189166df458bb8b046958bd74d40 (patch)
tree8992c9ba36fe98af1066337c9bb1103f9256fe07 /app/src/main/java/ml/docilealligator/infinityforreddit
parent580f9d24590e2738bfb1428214003af53b689432 (diff)
downloadinfinity-for-reddit-4c762f4bd9a9189166df458bb8b046958bd74d40.tar
infinity-for-reddit-4c762f4bd9a9189166df458bb8b046958bd74d40.tar.gz
infinity-for-reddit-4c762f4bd9a9189166df458bb8b046958bd74d40.tar.bz2
infinity-for-reddit-4c762f4bd9a9189166df458bb8b046958bd74d40.tar.lz
infinity-for-reddit-4c762f4bd9a9189166df458bb8b046958bd74d40.tar.xz
infinity-for-reddit-4c762f4bd9a9189166df458bb8b046958bd74d40.tar.zst
infinity-for-reddit-4c762f4bd9a9189166df458bb8b046958bd74d40.zip
Let MediaScannerConnection to scan the downloaded Reddit videos after downloading to make the video shows up in WhatsApp.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java
index 648639c2..3da24433 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java
@@ -13,6 +13,7 @@ import android.media.MediaCodec;
import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.media.MediaMuxer;
+import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
@@ -225,12 +226,17 @@ public class DownloadRedditVideoService extends Service {
}
EventBus.getDefault().post(new DownloadRedditVideoEvent(false));
} else {
- Intent intent = new Intent();
- intent.setAction(android.content.Intent.ACTION_VIEW);
- intent.setDataAndType(destinationFileUri, "video/*");
- PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
- updateNotification(R.string.downloading_reddit_video_finished, fileName, pendingIntent);
- EventBus.getDefault().post(new DownloadRedditVideoEvent(true));
+ MediaScannerConnection.scanFile(
+ this, new String[]{destinationFileUri.toString()}, null,
+ (path, uri) -> {
+ Intent intent = new Intent();
+ intent.setAction(android.content.Intent.ACTION_VIEW);
+ intent.setDataAndType(destinationFileUri, "video/*");
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
+ updateNotification(R.string.downloading_reddit_video_finished, fileName, pendingIntent);
+ EventBus.getDefault().post(new DownloadRedditVideoEvent(true));
+ }
+ );
}
stopForeground(false);
}