<?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 Yuriy Mysochenko on Medium]]></title>
        <description><![CDATA[Stories by Yuriy Mysochenko on Medium]]></description>
        <link>https://medium.com/@sdex?source=rss-245c7a449f9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Flyoms5sQGEiLkkII3i02A.jpeg</url>
            <title>Stories by Yuriy Mysochenko on Medium</title>
            <link>https://medium.com/@sdex?source=rss-245c7a449f9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:43:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sdex/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[New MediaStore Trash API in Android R]]></title>
            <link>https://medium.com/@sdex/new-mediastore-trash-api-in-android-r-9a7000c4037?source=rss-245c7a449f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a7000c4037</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Yuriy Mysochenko]]></dc:creator>
            <pubDate>Fri, 21 Feb 2020 08:46:26 GMT</pubDate>
            <atom:updated>2020-02-21T08:46:26.103Z</atom:updated>
            <content:encoded><![CDATA[<p>Along with many restrictions new android R brings some new useful APIs. One of them is a new Trash API:</p><p>MediaStore#createTrashRequest(ContentResolver, Collection&lt;Uri&gt;, boolean)</p><p>The method returns an instance of PendingIntent which should be used to prompt the user to move selected files to the trash using:</p><pre>startIntentSenderForResult<strong><em>(<br>    </em></strong>intentSender,<br>    <em>DELETE_PERMISSION_REQUEST</em>,<br>    <strong>null</strong>,<br>    0,<br>    0,<br>    0,<br>    <strong>null<br><em>)</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ocihDE2nhzg7C3vIvCIR8g.png" /><figcaption>Final result</figcaption></figure><p>In order to demonstrate this API in action <a href="https://github.com/sdex/MediaStoreTrashAPI">I’ve forked</a> <a href="https://github.com/android/storage-samples/tree/master/MediaStore">MediaStore</a> sample app and replaced permanent removing by moving to the trash.</p><p>The main difference is located in view model:</p><p><a href="https://github.com/sdex/MediaStoreTrashAPI/commit/7fcfa09a961035efa165a6e1e838e7901985430e#diff-4593100bf95581a7c3d8976847fe7497">use new Trash API · sdex/MediaStoreTrashAPI@7fcfa09</a></p><p>In order to determine whether the media file is in the trash or not a new column MediaColumns#IS_TRASHED is added.</p><p>Also MediaStore#QUERY_ARG_MATCH_TRASHED should help to filter files from the trash.</p><p>Links:</p><p><a href="https://developer.android.com/reference/android/provider/MediaStore#createTrashRequest(android.content.ContentResolver,%20java.util.Collection%3Candroid.net.Uri%3E,%20boolean)">MediaStore#createTrashRequest</a> documentation</p><p><a href="https://github.com/sdex/MediaStoreTrashAPI">Demo repository on GitHub</a></p><p>LinkedIn: <a href="https://www.linkedin.com/in/ymysochenko/">https://www.linkedin.com/in/ymysochenko/</a></p><p>Twitter: <a href="https://twitter.com/sdexyz">https://twitter.com/sdexyz</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a7000c4037" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run Worker as foreground service]]></title>
            <link>https://medium.com/@sdex/run-worker-as-foreground-service-b607819fd263?source=rss-245c7a449f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b607819fd263</guid>
            <category><![CDATA[workmanager]]></category>
            <category><![CDATA[foreground-service]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Yuriy Mysochenko]]></dc:creator>
            <pubDate>Fri, 06 Dec 2019 12:27:07 GMT</pubDate>
            <atom:updated>2020-02-21T06:46:21.814Z</atom:updated>
            <content:encoded><![CDATA[<h3>WorkManager: use foreground service for executing long running tasks</h3><p>WorkManager is a great library to execute background jobs and supporting foreground services makes it even better.</p><p>WorkManager supports executing long running tasks in foreground service since <a href="https://developer.android.com/jetpack/androidx/releases/work#2.3.0-alpha02">2.3.0-alpha02</a>. All you need is just to call ListenableWorker#setForegroundAsync() (or CoroutineWorker#setForeground() for Kotlin) and pass ForegroundInfo object. Let’s see how it works.</p><p><em>Note: I use WorkManager 2.3.0-beta01 some API may change in the future.</em></p><p>TL;DR source code available here:</p><p><a href="https://github.com/sdex/WorkManagerForeground">sdex/WorkManagerForeground</a></p><p>Foreground service requires notification (don’t forget that for android 8+ notification channel should be created before showing any notification):</p><pre><strong>val </strong>notification = NotificationCompat.Builder<strong><em>(</em></strong><em>applicationContext</em>, <strong>channelId<em>)<br>    </em></strong>.setSmallIcon<strong><em>(</em></strong>R.mipmap.<em>ic_launcher</em><strong><em>)<br>    </em></strong>.setContentTitle<strong><em>(</em>&quot;Important background job&quot;<em>)<br>    </em></strong>.build<strong><em>()</em></strong></pre><p>Then need to create ForegroundInfo object and pass notification as parameter:</p><pre><strong>val </strong>foregroundInfo = ForegroundInfo<strong><em>(</em></strong>notification<strong><em>)</em></strong></pre><p>And run the worker in foreground service:</p><pre>setForeground<strong><em>(</em></strong>foregroundInfo<strong><em>)</em></strong></pre><p>And that’s all, your worker is run in foreground service.</p><p>You can observe the progress:</p><pre>workManager.getWorkInfoByIdLiveData<strong><em>(</em></strong>workRequest.<em>id</em><strong><em>)<br>    </em></strong>.observe<strong><em>(</em>this</strong>, <em>Observer </em><strong>{ </strong>workInfo: WorkInfo? <strong>-&gt;<br>        if <em>(</em></strong>workInfo != <strong>null<em>) {<br>            </em>val </strong>progress = workInfo.<em>progress<br>            </em><strong>val </strong>value = progress.getInt<strong><em>(</em></strong><em>Progress</em>, 0<strong><em>)<br>            </em>binding</strong>.<strong>progressBar</strong>.<em>progress </em>= value<br>        <strong><em>}<br>    </em>}<em>)</em></strong></pre><p>Let’s run the app and make sure everything works fine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vPhnRdnTtQb7cjFZvR4yFw.png" /></figure><p>The foregrouns service is started and the notification is shown. However, the notification doesn’t have progress bar and displays only text. WorkManager doesn’t provide API to interact with service notification. But there is a way…</p><p>In order to update notification we just need the notification id. And there is such id, but it’s declared as a constant in SystemForegroundDispatcher and there is no way to change it. I hope the WorkManager team will provide either ability to create own notification id or a way to set notification progress in the future.</p><p>And before we just use the value from SystemForegroundDispatcher:</p><pre><em>// constants<br></em>@VisibleForTesting<br><strong>public static final int <em>NOTIFICATION_ID </em></strong>= 42;</pre><p>Now, adding progress bar to the notification is easy:</p><pre><strong>val </strong>notification = NotificationCompat.Builder<strong><em>(</em></strong><em>applicationContext</em>, <strong>channelId<em>)<br>    </em></strong>.setSmallIcon<strong><em>(</em></strong>R.mipmap.<em>ic_launcher</em><strong><em>)<br>    </em></strong>.setContentTitle<strong><em>(</em>&quot;Important background job&quot;<em>)<br>    </em></strong>.setProgress<strong><em>(</em></strong>100, progress, <strong>false<em>)<br>    </em></strong>.build<strong><em>()<br></em>notificationManager</strong>?.notify<strong><em>(</em></strong>42, notification<strong><em>)</em></strong></pre><p>Now it looks better:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-BD-dnCTSYXRCCp7j-QxLg.png" /></figure><p>The foreground service is stopped when a worker is done its job, the notification is removed automatically.</p><p><em>UPD 0:</em> As I have been <a href="https://twitter.com/tikurahul/status/1203069673228521473">told</a> there is another way to update notification, calling setForeground multiple times updates the notification too.</p><p><em>UPD 1</em>: In stable version the API is slightly changed, now you can pass notification id to ForegroundInfo constructor.</p><p>The complete project is available on GitHub:</p><p><a href="https://github.com/sdex/WorkManagerForeground">sdex/WorkManagerForeground</a></p><p>LinkedIn: <a href="https://www.linkedin.com/in/ymysochenko/">https://www.linkedin.com/in/ymysochenko/</a></p><p>Twitter: <a href="https://twitter.com/sdexyz">https://twitter.com/sdexyz</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b607819fd263" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to change ANDROID_ID on Android 8+ (Oreo) with ROOT]]></title>
            <link>https://medium.com/@sdex/how-to-change-android-id-on-oreo-with-root-a71ebbc38cec?source=rss-245c7a449f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a71ebbc38cec</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-oreo]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[root-android-app]]></category>
            <dc:creator><![CDATA[Yuriy Mysochenko]]></dc:creator>
            <pubDate>Tue, 03 Apr 2018 13:39:10 GMT</pubDate>
            <atom:updated>2023-08-14T13:00:52.946Z</atom:updated>
            <content:encoded><![CDATA[<p>ANDROID_ID (Settings.Secure.ANDROID_ID or SSAID) is a 64-bit number (expressed as a hexadecimal string), the one of key identifiers that widely used by applications to track users. Starting from Android 8 (Oreo), the ID has a different value for each application and each user on the device. For the previous android versions, the ID used to be unique for each user on the device but stayed the same for all apps.</p><p><strong>TL:DR</strong> <a href="https://github.com/sdex/AndroidIDeditorV2">https://github.com/sdex/AndroidIDeditorV2</a></p><p><strong>Denial of responsibility</strong><br>Anything you do that is described in this article is at your own risk. No one else is responsible for any data loss, corruption, or damage to your device, including that which results from bugs in this software. There is a nonzero chance of any of these events happening as a result of using the tools or methods here.</p><p>The system stores the list of assigned IDs to the applications in this file:</p><p>/data/system/users/0/settings_ssaid.xml</p><p>The XML file consists of setting for each app that has access to ID:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c42941617567dfdd237b8fd6097b0aa7/href">https://medium.com/media/c42941617567dfdd237b8fd6097b0aa7/href</a></iframe><p>Changing the ID as simple as editing text file: <br>1. Make sure that you have <strong>ROOT</strong> on your device.<br>2. Open the file /data/system/users/0/settings_ssaid.xml with any editor that supports ROOT.<br>3. Change value and defaultValue to a new Android ID for a desired application (identified by package).<br>4. <strong>Save the file</strong> <strong>and reboot your device to apply the changes.</strong></p><p>I’ve created a simple application <a href="https://github.com/sdex/AndroidIDeditorV2">Device ID Changer</a> that takes care about all this routine. All you need is just select an application and input a desired Android ID or use generator to set random value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*6Y98GcoMHk8SWYk5Zl7Xyw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*jh0Z4ZjAhi7Y1Q7KL7RCDg.png" /></figure><p>The application source code and binary:</p><p><a href="https://github.com/sdex/AndroidIDeditor">GitHub - sdex/AndroidIDeditor: Android ID editor</a></p><p>If you need to change the device ID for android 12 and above:</p><p><a href="https://github.com/sdex/AndroidIDeditorV2">GitHub - sdex/AndroidIDeditorV2: Android ID editor for Android 12+</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a71ebbc38cec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>