<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mateusz Kaflowski on Medium]]></title>
        <description><![CDATA[Stories by Mateusz Kaflowski on Medium]]></description>
        <link>https://medium.com/@mkaflowski?source=rss-29b70eb6c8e3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YdzmIH3iHpflk_Ce0d_5oQ.jpeg</url>
            <title>Stories by Mateusz Kaflowski on Medium</title>
            <link>https://medium.com/@mkaflowski?source=rss-29b70eb6c8e3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 15:37:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mkaflowski/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Disappearing files downloaded by DownloadManager]]></title>
            <link>https://medium.com/@mkaflowski/disappearing-files-downloaded-by-downloadmanager-7c9ee5c6a66a?source=rss-29b70eb6c8e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c9ee5c6a66a</guid>
            <category><![CDATA[download-manager]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Mateusz Kaflowski]]></dc:creator>
            <pubDate>Wed, 05 Feb 2020 13:30:09 GMT</pubDate>
            <atom:updated>2020-02-05T13:34:53.838Z</atom:updated>
            <content:encoded><![CDATA[<p>Android system DownloadManager is probably the most simple way to download files. Most people do not know that there is a hidden trap and the system can delete files(and probably will do it) that were downloaded and used more that a week ago and was set to be not visible (by <a href="https://developer.android.com/reference/android/app/DownloadManager.Request#setVisibleInDownloadsUi(boolean)">setVisibleInDownloadsUi</a>). This is caused by the system service called <a href="https://android.googlesource.com/platform/packages/providers/DownloadProvider/+/master/src/com/android/providers/downloads/DownloadIdleService.java#110">DownloadIdleService</a> which invokes cleanStale() which says:</p><blockquote>“Remove stale downloads that third-party apps probably forgot about. We only consider non-visible downloads that haven’t been touched in over a week.”</blockquote><p>There is a bigger problem starting in Android Q where value set by <a href="https://developer.android.com/reference/android/app/DownloadManager.Request#setVisibleInDownloadsUi(boolean)">setVisibleInDownloadsUi</a> is ignored and it is false by default. The files will be deleted after a week. You can reproduce it by:</p><ul><li>download file,</li><li>change date in calendar by 2 months for example</li><li>call this in terminal: <strong>adb shell cmd jobscheduler run -f com.android.providers.downloads -100</strong></li></ul><p>The last one starts job from <a href="https://android.googlesource.com/platform/packages/providers/DownloadProvider/+/master/src/com/android/providers/downloads/DownloadIdleService.java#110">DownloadIdleService</a> where old and forbidden files are deleted. You can see in logcat (set no filter) that DownloadManager try to delete your files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*Ng-Qic2Af_4v11GFP02lrg.png" /></figure><p>To prevent from that you can:</p><ul><li>download files to<strong>Environment#getExternalStoragePublicDirectory(String) with Environment#DIRECTORY_DOWNLOADS)</strong> - this is the only path starting in Android Q where downloads are visible and should not be deleted</li><li>change file name after downloading (in DownloadedReceiver for example)</li></ul><p>And thats it. I hope that it is helpful for someone :) I have spent a lot of time for searching why my files disappear.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c9ee5c6a66a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sending media to Chromecast has never been easier (Exoplayer cast extension)]]></title>
            <link>https://medium.com/android-news/sending-media-to-chromecast-has-never-been-easier-c331eeef1e0a?source=rss-29b70eb6c8e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c331eeef1e0a</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[exoplayer]]></category>
            <category><![CDATA[chromecast]]></category>
            <dc:creator><![CDATA[Mateusz Kaflowski]]></dc:creator>
            <pubDate>Thu, 22 Mar 2018 14:25:11 GMT</pubDate>
            <atom:updated>2018-04-05T12:34:38.461Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*vcrQLnsXD1did2-pBsGDrQ.jpeg" /></figure><p>If you have been implemented Chromecast handling in your app you probably noticed that it is a little bit complicated and tricky. Some thing just doesn’t want to work. Thanks to new ExoPlayer extension it is a lot of easier now.</p><h4>Import libraries.</h4><p>You need to import libraries first. Just add them in gradle file:</p><pre>compile &#39;com.google.android.exoplayer:exoplayer:2.7.0&#39;<br>compile &#39;com.google.android.exoplayer:extension-cast:2.7.0&#39;</pre><p>If you are using some com.google.android.gms libraries (Firebase for example) you can see some inconsistency warnings. You can fix that by adding:</p><pre>compile &#39;com.google.android.gms:play-services-cast-framework:&lt;YOUR_VERSION&gt;&#39;</pre><h4>Declare an OptionProvider.</h4><p>Declare an OptionProvider class in the app’s AndroidManifest.xml in. This will allow specifying the receiver app.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a33e13c8f4e3b0fb01e0a8ab09c1ca7/href">https://medium.com/media/8a33e13c8f4e3b0fb01e0a8ab09c1ca7/href</a></iframe><h4>Add UI elements.</h4><p>First of all you need to add some user interface elements for connecting with your Chromecast receiver. The easiest way is to add <a href="https://developer.android.com/reference/android/support/v7/app/MediaRouteButton.html">MediaRouteButton</a> just like in official doc.</p><p>As option in toolbar:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6889240594fbcfe2375e3e358ea1910/href">https://medium.com/media/c6889240594fbcfe2375e3e358ea1910/href</a></iframe><p>As view:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22ef62f52d85fe0388fa1d58f1e6c2da/href">https://medium.com/media/22ef62f52d85fe0388fa1d58f1e6c2da/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*goK9pPfOybUnhIfkV8a40g.jpeg" /></figure><p>I have noticed that MediaRouteButton as a view doesn’t show up on Chromecast available which works well in menu version so I do something like that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/900687fb489aa103cd17fca01a1f4da9/href">https://medium.com/media/900687fb489aa103cd17fca01a1f4da9/href</a></iframe><p>It is also good to initialize CastContext in onCreate() to avoid some strange glitches like missing notification:</p><pre>CastContext castContext = CastContext.<em>getSharedInstance</em>(this);</pre><p>Add Proguard rules:</p><pre># Accessed via menu.xml<br><strong>-keep </strong>class android.support.v7.app.MediaRouteActionProvider {<br>  *;<br>}</pre><h4>Declare media source and connect to Chromecast receiver.</h4><p>Create media queue:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88c9806db51c924cf8515f5eaca5d41a/href">https://medium.com/media/88c9806db51c924cf8515f5eaca5d41a/href</a></iframe><p>Create CastPlayer object and handle media queue:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a580fcdfe2e607511b8e336479c4a69/href">https://medium.com/media/2a580fcdfe2e607511b8e336479c4a69/href</a></iframe><p>And that’s it! Don’t forget to release CastPlayer with realease(). You can control player with built-in methods like seek(), pause() and so on. For selecting stream from queue use: seekTo(windowIndex, msec).</p><h4>Can I make it easier and connect it with player on sender phone?</h4><p>Yes and yes!</p><p>I have made player library to make playing audio and video on your phone and integrating with Chromecast even easier. I will write about it soon!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e491f%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e491f%2F&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e491f%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href">https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c331eeef1e0a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/sending-media-to-chromecast-has-never-been-easier-c331eeef1e0a">Sending media to Chromecast has never been easier (Exoplayer cast extension)</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>