<?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 \n Malyshev Yegor \n on Medium]]></title>
        <description><![CDATA[Stories by \n Malyshev Yegor \n on Medium]]></description>
        <link>https://medium.com/@brainail?source=rss-5468063993e9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1GNktQpZqM48r9B8l5bqxg.jpeg</url>
            <title>Stories by \n Malyshev Yegor \n on Medium</title>
            <link>https://medium.com/@brainail?source=rss-5468063993e9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:57:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brainail/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[JetPack Android WorkManager Library - some details under the hood ]]></title>
            <link>https://medium.com/android-news/androidx-workmanager-%EF%BE%89-%EF%BE%89-some-details-under-the-hood-a5ca1099c93?source=rss-5468063993e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5ca1099c93</guid>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[android-architecture]]></category>
            <category><![CDATA[jobscheduler]]></category>
            <category><![CDATA[workmanager]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[\n Malyshev Yegor \n]]></dc:creator>
            <pubDate>Thu, 10 May 2018 19:17:20 GMT</pubDate>
            <atom:updated>2018-05-14T08:04:19.645Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fmeVJsh93qBdDFgKU1lyWA.jpeg" /></figure><p>Hi everyone ⊂( ◜◒◝ )⊃,</p><p>so lots of articles basically show APIs from a bird’s-eye view, but for such purposes, I would rather explore documentation first. That’s why today I want to show you a short explanation what lies under the hood of new <strong>Architecture Component</strong> that has been announced just recently at <a href="https://events.google.com/io">Google I/O 2018</a> and I am talking about <a href="https://developer.android.com/topic/libraries/architecture/workmanager">WorkManager</a> from <a href="https://developer.android.com/jetpack/">JetPack</a>.</p><h3>Top layerヾ(ﾟ∀ﾟ○)ﾂ</h3><p>So, before any use to make it work you have to prepare your environment, namely include the right dependency and you are good to go:</p><pre>implementation &quot;android.arch.work:work-runtime:1.0.0-alpha01&quot;</pre><pre>// if you want some benefits from Kotlin then try this<br>implementation &quot;android.arch.work:work-runtime-ktx:1.0.0-alpha01&quot;</pre><p>Now let’s create some <strong>Work</strong> quickly and start it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c58033cabe44c7af5288ec31834325b2/href">https://medium.com/media/c58033cabe44c7af5288ec31834325b2/href</a></iframe><p>So, looks pretty. But wait I’m a bit busy (or just work “<em>hardly</em>”) and want to stop my hard work right now. And yes we, of course, have such method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01c561a78f4c394b84f16e6a1b9cf768/href">https://medium.com/media/01c561a78f4c394b84f16e6a1b9cf768/href</a></iframe><p>As you can see here we use a method called cancelWorkById(UUID). There are other methods to stop your particular work or chain of works or whatever (by tags or by unique name). Because we don’t generate it on our own there are possibilities (see below) that collision will happen and if you start some really important job and then start some plain unrelated job and want to stop it but <a href="https://developer.android.com/reference/java/util/UUID">UUID</a> is the same for both therefore bad things will happen (<strong>tip</strong>: use tags if you care).</p><p>From <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier#Collisions">Wikipedia</a> it seems like almost impossible to have a collision but it also means that we can’t fully rely on it… Also, I’m not sure why the method to retrieve <em>UUID</em> returns the actual object. I think such details should be hidden. Also as a solution to have some guarantees the generation process could be changed to something like this: currentTimeMillis + &#39;-&#39; + UUID. Meow? Anyway Google’s guys know what they do and do their job well and I’m serious here.</p><h3>Middle layerヾ(ﾟ∀ﾟ○)ﾂ</h3><p>So, maybe you think that I’m going to just list all methods and explain them… Sorry but not. The documentation is pretty nice for <strong>Architecture Components </strong>and it’s boring to explain it again here. Let’s try to find out some interesting details. In short, <strong>WorkManager</strong> is here for some reasons but mostly it’s like <a href="https://developer.android.com/reference/android/app/job/JobScheduler">JobScheduler</a> or similar libraries. What kind of reasons? I think there are at least three major reasons:</p><ul><li><strong>Backward compatibility</strong>. Before it, we weren’t able to have one solution for everything (of course I’m wrong and there were some but not directly from Google).</li><li><strong>Monitoring, observability</strong>. What does such math words mean here? It means that at any moment you are able to know what happens with your work, see current outputs, monitor it. Yeah, it was possible (hardly) for some solutions but it wasn’t so easy as here.</li><li><strong>Guarantees</strong>. It means that whatever happens your work will be performed.</li></ul><p>and there are at least three things (please explore them using coming video from Youtube or documentation) which differ it from other competitors and for sure it’s awesome:</p><ul><li><em>Inputs</em> (provide input data for works) / <em>Outputs</em> (set output data for works). Using <em>In/Out</em> mechanism you are able to pass data from chain of works to some major work or whatever scenario you think about. Also to deal with conflicts you are able to provide your own <em>merger</em>! The only one thing that should be considered carefully it’s a size of your data. Looks like it’s about <strong>10 KB</strong> (maybe yes and maybe not it depends you know). But I think it’s a reasonable choice of course and calculated carefully too. Niceeeeee.</li><li><em>Chained works</em>. Just imagine that you are able to run 3 works in parallel and only then compute something based on the results from them and then upload your results somewhere else and provide conditions to deal with battery and networks! <br>Sweeeeeet.</li><li><em>Unique works</em>. For instance you have 3 different triggers in your system but you want to do the same work for each of them and of course we want to do it once but react on all of them and if some is already enqueued then you want for different reasons <em>REPLACE</em> (start new one and forget about old one) / <em>APPEND</em> (let it finish and start a new one) / <em>KEEP</em> (let it finish and skip the current) it. Yay! We have such ability. Just create a unique work, provide some unique name for it, provide a work policy when you schedule a work with the same name and schedule it. Then you are able to schedule your new unique work with the same name and <strong>WorkManager</strong> will solve your problem like a piece of cake. <br>Awesoooome.</li></ul><h4>✪ Backward compatibility:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8242a63f25d3b193a50eee8fae34067/href">https://medium.com/media/b8242a63f25d3b193a50eee8fae34067/href</a></iframe><p>Above you are able to see the source code (even if it’s in Java there I convert it to Kotlin to keep everything consistent, sorry) from the library itself. Everything is easy here, two main schedulers are created.</p><p><strong>First</strong> is the best of the best:</p><ul><li>try <a href="https://developer.android.com/reference/android/app/job/JobScheduler">JobScheduler</a></li><li>then <a href="https://github.com/firebase/firebase-jobdispatcher-android">FirebaseScheduler</a> (you need additional dependency for that, i.e. implementation &quot;android.arch.work:work-firebase:1.0.0-alpha01&quot;)</li><li>if no luck before then use <a href="https://developer.android.com/reference/android/app/AlarmManager">AlarmScheduler</a></li></ul><p><strong>Second</strong> is for instancy (if a phone is active enough then why not?). So if your work is really simple in terms of conditions and it’s not periodic and there is no start delay for it and when all conditions are met then <strong>WorkManager</strong> starts it and if it’s done before the same work on the first scheduler then we are good to go. Purposes of it to let your work be done as soon as possible because there are no guarantees when the first scheduler will perform it. Sounds pretty reasonable.</p><h4>✪ Observability:</h4><p>As we have already seen above it’s possible to retrieve <a href="https://developer.android.com/reference/android/arch/lifecycle/LiveData">LiveData</a> object for any of your work (by <em>UUID</em>, <em>tags</em>, <em>names</em>, etc.). Sounds really handy because as we know such observation is lifecycle aware (if you observe properly of course). Also, it’s great because you don’t need to check and check and check and again check it every <em>X-</em>seconds and you will know about results as soon as possible.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8aa59eb86e248eed23ce716c7ea805d0/href">https://medium.com/media/8aa59eb86e248eed23ce716c7ea805d0/href</a></iframe><p>Also if you are on some background thread already and you just want to check your status right now and forget about future then we are lucky because all methods (also for <em>enqueuing</em>) are duplicated in a synchronous manner.</p><p>Where is the magic? Oh boy… Magic is done via other great things as <a href="https://developer.android.com/topic/libraries/architecture/room">Room</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5036f4e942e04ae02bec0e2f9515d287/href">https://medium.com/media/5036f4e942e04ae02bec0e2f9515d287/href</a></iframe><p>So actually we just fetch statuses from <em>DAO </em>and<em> </em>observe them via <a href="https://developer.android.com/reference/android/arch/lifecycle/MediatorLiveData">MediatorLiveData</a> to map our <em>POJOs</em> to the final statuses. Pretty handy right?</p><h4>✪ <strong>Guarantees</strong>:</h4><p>Oh yeah, guarantees it’s one of the nicest things of course. No one would like to live in the unstable world. And here we don’t have any!</p><p>As I mentioned above internally <em>Room’s</em> stuff is used to make you happy. So before starting any work, <strong>WorkManager</strong> records it via <em>Room</em>. Then any time when something should be changed about status, output data, etc., will be handled via <em>Room’s</em> transaction to guarantee that everything is synchronized.</p><p>For instance, if your work fails and you set before several attempts for your <em>Work</em> what do you expect next? The following methods will help you to understand the main concept:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fda65aa72ba54ddb32d00007dfcb1966/href">https://medium.com/media/fda65aa72ba54ddb32d00007dfcb1966/href</a></iframe><p>It’s pretty crystal clear. Update attempts and continue. But wait! What’s about all input/output data, conditions and my <strong>Worker</strong> class! And as you are able to see from <a href="https://codelabs.developers.google.com/codelabs/android-workmanager/#4">codelabs</a> (or documentation) everything is eventually kinda <a href="https://developer.android.com/reference/android/os/Parcelable">Parcelable</a> and it’s, of course, possible to store in <em>Room</em>. Holy-moly, but it’s just about params, what’s about my <strong>Worker</strong> class? The same story here. As you will see during your journey that actually you don’t have abilities to create something bad and pass it to WorkManager and thus break things. Your related class-name will be stored as well and instantiated when its time will come.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/171d4c236b6389bdf6f4b9fc3adcdffe/href">https://medium.com/media/171d4c236b6389bdf6f4b9fc3adcdffe/href</a></iframe><p>That’s why you have yours guarantees and everything will be done eventually.</p><h3>ヽ( ´ー`)ノ</h3><p>Here comes outcome. What do we have? We have a really powerful manager for our works! Actually, I just described the general things which go right underneath the <strong>WorkManager</strong>. Lots of code there and it smells tasty. I hope that you got the main idea. To see the real example I recommend <a href="https://codelabs.developers.google.com/codelabs/android-workmanager/#4">codelabs</a> because lots of stuff goes there. And yes <strong>WorkManager</strong> is documented really well. This is how any public library should look. Because it’s still alpha some things can be broken in <a href="https://github.com/googlesamples/android-architecture-components/issues/356">extreme cases</a> but from my point of view it’s ready at least for your pet projects to taste and to leave some feedback if you find some uncomfortable or broken things.</p><p>Probably you are wondering about testing. Don’t worry, it’s <a href="https://developer.android.com/jetpack/">JetPack</a> and it has such item: androidTestImplementation &quot;android.arch.work:work-testing:1.0.0-alpha01&quot;.</p><p>Also please keep in mind that you should use <strong>WorkManager</strong> for right things and don’t forget to use conditions to make phones happy (<em>battery life</em>, <em>network traffic</em>, etc.):</p><ul><li>Upload stuff to a server 🍏</li><li>Process data and store it in database 🍏</li><li><strong>Don’t use it</strong> in order to apply some image filter and display the result in <a href="https://developer.android.com/reference/android/widget/ImageView">ImageView</a> instantly on the same screen 🍎</li></ul><p>Useful links to keep your attention once again:ヾ(･ω･)ｼ</p><ul><li><a href="https://codelabs.developers.google.com/codelabs/android-workmanager/">Codelabs</a></li><li><a href="https://developer.android.com/topic/libraries/architecture/workmanager">Developers</a></li></ul><p>Thanks for listening. Bye-bye °˖✧◝(⁰▿⁰)◜✧˖°</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=a5ca1099c93" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/androidx-workmanager-%EF%BE%89-%EF%BE%89-some-details-under-the-hood-a5ca1099c93">JetPack Android WorkManager Library - some details under the hood 👷</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>
        <item>
            <title><![CDATA[Android Paging Library — Make your lists as efficient as possible literally in just an hour…]]></title>
            <link>https://medium.com/android-news/android-paging-library-make-your-lists-as-efficient-as-possible-literally-in-just-an-hour-5abf797585bd?source=rss-5468063993e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5abf797585bd</guid>
            <category><![CDATA[network]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[\n Malyshev Yegor \n]]></dc:creator>
            <pubDate>Sun, 17 Sep 2017 13:31:39 GMT</pubDate>
            <atom:updated>2017-11-19T15:18:12.769Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YiM5KahweZ2ifVJjs_Hj8g.jpeg" /><figcaption>Image from <a href="https://www.pexels.com/photo/book-books-circle-curly-87007/">Pexels</a></figcaption></figure><h3>Android Paging Library — Make your lists as efficient as possible literally in just an hour directly from the network! ヽ(*・ω・)ﾉ</h3><p>So, the new <a href="https://developer.android.com/topic/libraries/architecture/paging.html"><strong>Paging Library</strong></a> is coming to Android as a part of the <a href="https://developer.android.com/topic/libraries/architecture/index.html"><strong>Architecture Components</strong></a>. It’s still in alpha but there is no doubt that you are already ready to try it! And I’m not gonna tell you about the usage of all this stuff. Because this article it’s just a short addition of the great article by <a href="https://medium.com/u/3d28300b4253">Chris Craik</a> that you are able to read <a href="https://medium.com/google-developers/large-database-queries-on-android-cb043ae626e8"><strong>here</strong></a>. <br>So, when you should use it. Ok, if you gradually load information as needed from a data source and you don’t wanna overload the device or wait too long for a big database query then probably it’s the right moment to try it.</p><p>Because from the examples at first glance it seems like all those nano technology<strong> </strong>work only with <a href="https://developer.android.com/topic/libraries/architecture/room.html"><strong>Room</strong></a> we might wanna avoid the usage of the library if we don’t need it. Let’s see a short example, implement it and prove that there is some hope.</p><p>Ok, imagine that we wanna write some test application in order to test our API. We don’t wanna use any database or storage but we still wanna do it efficiently and don’t load all data at once because it will be horrible application even if it’s only for test purposes. What are you thinking about in the first place. Yeah, I’m sure about some tricky <a href="https://stackoverflow.com/a/26643292/5495606"><strong>onScrollListener</strong></a> or about the approach with binding of the last item through the <a href="https://stackoverflow.com/a/32110117/5495606"><strong>ViewHolder</strong></a><strong> </strong>to know the right time to start fetching. Anyway, you are thinking about some sorta paging to fetch data only when we need it. But while we are in the process of thinking we lose the idea of the fast check of our API. Ok then let’s see what we’ve got with this library.</p><p>As an example we are gonna test <a href="https://kitsu.io/explore/anime"><strong>Kitsu</strong></a> API (yeah, I like such kinda stuff ). And we have a simple task. We just wanna display a list with some content fetched using our API. And yes, our API support <strong>paging</strong>! So, it’s a sign! (ﾉ´ヮ`)ﾉ*: ･ﾟ</p><h3>Screen</h3><p>So, we definitely need the main thing like <strong>Activity</strong> with our list:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22d99d2ea3f67008ba2580fec9e5cf6f/href">https://medium.com/media/22d99d2ea3f67008ba2580fec9e5cf6f/href</a></iframe><p>nothing special here. We have our simple <a href="https://developer.android.com/topic/libraries/architecture/viewmodel.html"><strong>ViewModel</strong></a>. Our layout contains only <strong>RecyclerView</strong> to display data and some search view to specify some particular query. By default we search for something to display at least some fancy results because I have no time for <em>shiny empty view</em> here. Also notice that there won’t be any sorta <strong>clean patterns</strong> and super-duper <strong>Kotlin’s stuff</strong>. Thanks for understanding because it’s just an example (＞﹏＜)</p><h3>ViewModel</h3><p>Right. There is more. Let’s do it just step by step with some brief explanation. Now we need to explore our <strong>ViewModel</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/91daaeba2a19b7e4afc01815c5ac9bf3/href">https://medium.com/media/91daaeba2a19b7e4afc01815c5ac9bf3/href</a></iframe><p>Every time when we specify some new query we need to update our datasource to be up-to-date and fetch the right data and also we invalidate our current <a href="https://developer.android.com/topic/libraries/architecture/livedata.html"><strong>LiveData</strong></a> to use fresh one later. Please notice the important moment that to use the undefined number of items (<a href="https://developer.android.com/reference/android/arch/paging/DataSource.html#COUNT_UNDEFINED"><strong>DataSource#COUNT_UNDEFINED</strong></a>) easily (because I really have no idea beforehand how much items I have) we have to disable placeholders (or make it as contiguous). Why? Because if we wanna use them and see nice empty views while data in the loading process then we have to specify <strong>the exact number of items</strong>. Ok, keep moving!</p><h3>PagedListProvider</h3><p>Let’s see how our provider for <a href="https://developer.android.com/reference/android/arch/paging/PagedList.html"><strong>PagedList</strong></a> looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a4bc7a7df1aa8f2acecbfcd6665c397/href">https://medium.com/media/6a4bc7a7df1aa8f2acecbfcd6665c397/href</a></iframe><p>Here we create our <a href="https://developer.android.com/reference/android/arch/paging/DataSource.html"><strong>DataSource</strong></a> based on the abstract custom <strong>DataSource</strong> to be able to override the behaviour of the conversion (we don’t need it here, but just as an example). We backed it in the separated field to be able to change the query filter. And finally using this datasource we create <a href="https://developer.android.com/reference/android/arch/paging/LivePagedListProvider.html"><strong>LivePagedListProvider</strong></a> to create <a href="https://developer.android.com/reference/android/arch/paging/LivePagedListProvider.html#create(Key,%20android.arch.paging.PagedList.Config)"><strong>LiveData</strong></a> later. And yes you probably noticed that we also pass the API object to fetch our data using <a href="http://square.github.io/retrofit/"><strong>Retrofit</strong></a>.</p><h3>Data</h3><p>What kind of data do we have? No magic, it’s simple data that will be converted from the <strong>Retrofit’s call</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/231d15c95fbf943091dc98bb2560ec1a/href">https://medium.com/media/231d15c95fbf943091dc98bb2560ec1a/href</a></iframe><h3>Datasource</h3><p>Now it’s time to see how our abstract custom <strong>DataSource</strong> looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/764315f436b2ba0d4d1caa49d35188ff/href">https://medium.com/media/764315f436b2ba0d4d1caa49d35188ff/href</a></iframe><p>We use <a href="https://developer.android.com/reference/android/arch/paging/TiledDataSource.html"><strong>TiledDataSource</strong></a> to simplify the usage but it’s probably the wrong way because in a case of <strong>TiledDataSource</strong> we need <strong>some exact number of items</strong> but due to <em>disabled placeholders</em> it will be transformed to the <strong>ContiguousDataSource</strong> and everything will work magically. Because our API supports paging you see how easy to implement the <a href="https://developer.android.com/reference/android/arch/paging/TiledDataSource.html#loadRange(int,%20int)"><strong>loadRange</strong></a> method. And yes it’s safe to call some sorta long-running operations directly in the <strong>loadRange</strong> method because it’s called on the <em>background thread</em>.</p><h3>API</h3><p>Ok, look briefly at our API stuff:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f076742f1df428896b820f1e6220748c/href">https://medium.com/media/f076742f1df428896b820f1e6220748c/href</a></iframe><h3>Adapter &amp; ViewHolder</h3><p>I think we are almost done. Now it’s time for <em>UI parts</em>. <strong>Adapter</strong> and <strong>ViewHolder</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3d8fa3f6d55ae4a803c2d776eec79ae/href">https://medium.com/media/c3d8fa3f6d55ae4a803c2d776eec79ae/href</a></iframe><p>Nothing interesting about <strong>ViewHolder</strong>. Just my weird bind method with lots of <em>“Oughhh…”</em> stuff ヾ( ￣O￣)ツ More interestingly it’s that we <strong>extends </strong><a href="https://developer.android.com/reference/android/arch/paging/PagedListAdapter.html"><strong>PagedListAdapter</strong></a> and guess why? Because everything here is based on the concept of pages and this adapter is special one. Also we provide <a href="https://developer.android.com/reference/android/support/v7/recyclerview/extensions/DiffCallback.html"><strong>DiffCallback</strong> </a>to compare our items properly and perform more efficient changes in our list via a special internal <a href="http://www.xmailserver.org/diff2.pdf"><strong>diff algorithm</strong></a>.</p><h3>Output</h3><p>And that’ it! We are finally done! Congrats! But how does it work??? (￣0￣)<br>See below of course ᕕ( ᐛ )ᕗ</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgkWAarU-7GQ%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgkWAarU-7GQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FgkWAarU-7GQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ab62081ee63a2a8af6ed755826f1069/href">https://medium.com/media/9ab62081ee63a2a8af6ed755826f1069/href</a></iframe><p>And I almost forgot to mention that <a href="https://medium.com/u/fc3a05a526ab">Chris Craik</a> told us:</p><blockquote><a href="https://medium.com/@chriscraik/thanks-f38b1216a88"><em>Paging alpha1 doesn’t drop data — wanted to get that in, but wasn’t able to for the first alpha. Will be added in the future, and the in-memory max count will be configurable.</em></a></blockquote><p><strong>UPD:</strong> Don’t miss your chance to listen to a great episode with <a href="https://medium.com/u/d5885adb1ddf">Florina Muntenescu</a> about <a href="https://developer.android.com/topic/libraries/architecture/paging.html">Android Architecture Paging Library</a>! Check this out <a href="http://fragmentedpodcast.com/episodes/97/">here</a>! <br>Good luck! ヾ(｡･ω･)ｼ<br><strong>UPD: </strong>Handled the request about the source code, see it <a href="https://github.com/brainail/.samples/tree/master/ArchPagingLibraryWithNetwork">here</a>, the rough java version <a href="https://github.com/brainail/.samples/tree/master/ArchPagingLibraryWithNetworkJava">here</a>! ヽ( ･∀･)ﾉ</p><p>So… It’s great news! Stay tuned! And if you still read here then thank you very much ヾ(・ω・`)ノヾ(´・ω・)ノ゛Bye-bye! Cheers! ( ◡‿◡ *)</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=5abf797585bd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/android-paging-library-make-your-lists-as-efficient-as-possible-literally-in-just-an-hour-5abf797585bd">Android Paging Library — Make your lists as efficient as possible literally in just an hour…</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>
        <item>
            <title><![CDATA[Do you really like ConstraintLayout? Let’s see …]]></title>
            <link>https://medium.com/android-news/do-you-really-like-constraintlayout-lets-see-b11b8ef021a4?source=rss-5468063993e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b11b8ef021a4</guid>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[\n Malyshev Yegor \n]]></dc:creator>
            <pubDate>Sat, 04 Jun 2016 20:15:40 GMT</pubDate>
            <atom:updated>2016-06-05T07:41:52.083Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dL-63f_U9gWhT_FI4ACH0A.png" /></figure><h4>Introduction</h4><p>Recently at <em>Google I/O</em> was introduced <strong>ConstraintLayout:</strong> a new powerful and flexible Android layout that allows you to express complex UI without nesting multiple layouts. Wow! Sounds really great! Let’s take a look a little bit closer but briefly (・_・ヾ</p><h4>Installation</h4><p>OK, what should we have? It’s simple. We just need some pan, vegetables, seasoning &amp; fire! ｢(ﾟ&lt;ﾟ)ﾞ??</p><ul><li>Install the latest version of <a href="http://tools.android.com/download/studio/builds/2-2-preview-2"><strong>Android Studio 2.2</strong></a></li><li>Add dependency for the <strong>ConstraintLayout</strong> from the <em>support library</em>:</li></ul><pre><strong>compile &#39;com.android.support.constraint:constraint-layout:1.0.0-alpha2&#39;</strong></pre><blockquote>Bonus: the <strong>ConstraintLayout</strong> also has backward compatibility with API 9+</blockquote><p>That’s it! We are on the right way!</p><h4>What does lie behind it?</h4><p>Imagine the famous <a href="https://developer.android.com/reference/android/widget/RelativeLayout.html"><strong>RelativeLayout</strong></a> that we like to use when want to get rid of nested childs. Imagined? And now powder it using extra <em>attrs</em> from <a href="https://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html"><strong>PercentRelativeLayout</strong></a> (yes, I know that it includes <strong>RelativeLayout</strong> but generally we use raw <strong>RelativeLayout</strong>) plus all this stuff flies on the reactive plane.</p><p>Also let’s remember some main attrs from layouts described above and write a mapping between corresponding values of <strong>ConstraintLayout </strong>(please notice and don’t be angry that I omitted all mentions about {<strong>start/end</strong>} attrs just to be as short as possible). It will help your migration from one layout to another<strong>:</strong></p><ul><li><strong>RL</strong>: layout_toRightOf=”<em>@id/itemId</em>” ⇆ <strong>CL</strong>: layout_constraintLeft_toRightOf=”<em>@id/itemId</em>”</li><li><strong>RL</strong>: layout_toLeftOf=”<em>@id/itemId</em>” ⇆ <strong>CL</strong>: layout_constraintRight_toLeftOf=”<em>@id/itemId</em>”</li><li><strong>RL</strong>: layout_above=”<em>@id/itemId</em>” ⇆ <strong>CL</strong>: layout_constraintBottom_toTopOf=”<em>@id/itemId</em>”</li><li><strong>RL</strong>: layout_below=”<em>@id/itemId</em>” ⇆ <strong>CL</strong>: layout_constraintTop_toBottomOf=”<em>@id/itemId</em>”</li><li><strong>RL</strong>: layout_alignLeft=”<em>@id/itemId</em>” ⇆ <strong>CL</strong>: layout_constraintLeft_toLeftOf=”<em>@id/itemId</em>”</li><li><strong>RL</strong>: layout_alignRight=”<em>@id/itemId</em>” ⇆ <strong>CL</strong>: layout_constraintRight_toRightOf=”<em>@id/itemId</em>”</li><li><strong>RL</strong>: layout_alignTop=”<em>@id/itemId</em>” ⇆ <strong>CL</strong>: layout_constraintTop_toTopOf=”<em>@id/itemId</em>”</li><li><strong>RL</strong>: layout_alignBottom=”<em>@id/itemId</em>” ⇆ <strong>CL</strong>: layout_constraintBottom_toBottomOf=”<em>@id/itemId</em>”</li></ul><blockquote>to use the attrs below please assign some <strong>CLId</strong> for your <strong>ConstraintLayout</strong> and use it as some kinda anchor</blockquote><ul><li><strong>RL</strong>: layout_alignParentLeft=”<em>true</em>” ⇆ <strong>CL</strong>: layout_constraintLeft_toLeftOf=”<em>@id/CLId</em>”</li><li><strong>RL</strong>: layout_alignParentRight=”<em>true</em>” ⇆ <strong>CL</strong>: layout_constraintRight_toRightOf=”<em>@id/CLId</em>”</li><li><strong>RL</strong>: layout_alignParentTop=”<em>true</em>” ⇆ <strong>CL</strong>: layout_constraintTop_toTopOf=”<em>@id/CLId</em>”</li><li><strong>RL</strong>: layout_alignParentBottom=”<em>true</em>” ⇆ <strong>CL</strong>: layout_constraintBottom_toBottomOf=”<em>@id/CLId</em>”</li><li><strong>RL</strong>: layout_centerHorizontal=”<em>true</em>” ⇆ <strong>CL</strong>: layout_constraintLeft_toLeftOf=”<em>@id/CLId</em>” + layout_constraintRight_toRightOf=”<em>@id/CLId</em>” + layout_constraintHorizontal_bias=”<em>0.5</em>”</li><li><strong>RL</strong>: layout_centerVertical=”<em>true</em>” ⇆ <strong>CL</strong>: layout_constraintTop_toTopOf=”<em>@id/CLId</em>” + layout_constraintBottom_toBottomOf=”<em>@id/CLId</em>” + layout_constraintVertical_bias=”<em>0.5</em>”</li><li><strong>RL</strong>: layout_centerInParent=”<em>true</em>” ⇆ <strong>RL</strong>: layout_centerHorizontal=”<em>true</em>” + <strong>RL</strong>: layout_centerVertical=”<em>true</em>”</li></ul><blockquote>you are able to repeat the behaviour of some <strong>PercentRelativeLayout</strong>’s attrs using <strong>layout_constraintVertical_bias</strong> &amp; <strong>layout_constraintHorizontal_bias</strong> of <strong>ConstraintLayout. </strong>Please play with it by yourself.</blockquote><h4>Unique attrs</h4><p><strong>ConstraintLayout </strong>also has some unique useful attrs (maybe you will find some other attrs useful but right now there is no DOCs) like the following:</p><ul><li><strong>CL</strong>: layout_constraintBaseline_toBaselineOf ⇉ baseline constrain allows you to align the TextView’s baseline to other baselines.</li></ul><h4>Design/Layout Editor</h4><p>Editor has a new user interface designer that helps you visually design the layouts in your application. Features like <em>blueprint mode</em> and the new <em>properties panel</em> allow you to quickly edit layouts and widgets.</p><p>What’s new?</p><ul><li>Drag-and-drop widgets from the palette to the design surface ...</li><li>Design surface has a blueprint mode to inspect the spacing and arrangement of your app’s layout …</li><li>Properties panel now shows properties for quick widget edits with a full sheet of advanced properties in one click away…</li><li>UI builder can edit menu and system preference files …</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Whj9x8bpyIvLc0I7dPJIcg.png" /><figcaption>What I really love from the list above is <em>blueprint</em> mode. Nice to have it! Thanks.</figcaption></figure><h4>Does Layout Editor + ConstraintLayout = Love? ♥♥♥</h4><p>ConstraintLayout is tightly coupled with <strong>Android Studio</strong> and it was designed to be used in Studio and it can efficiently express your app design.</p><p>The point is that Layout Editor tries to do all work without any line of code from us. Generate all constraints, suggest constrains, show all stuff with very beautiful animations. Nice!</p><p>I won’t describe all new Editor’s stuff here. See my short list below to understand why <strong>Android Studio</strong> does all work:</p><ul><li><strong>Auto-connect</strong> ⇉ automatically calculates and sets the constraints for you when you add some new widget</li><li><strong>Manual constraint</strong> ⇉ add/remove all necessary constrains using mouse</li><li><strong>Inference</strong> ⇉ it’s like auto-connect feature but it automatically calculates and sets the constraints for you of all stuff on your screen</li><li><strong>Clear all constrains</strong> ⇉ clear all constraints on your screen (-_-)ゞ゛</li><li><strong>Show No constrains</strong> ⇉ all constrains are visible/invisible (-_-)ゞ゛</li><li><strong>Default screen margin</strong> ⇉ it’s nice to have some visual indicator that you are able to move your widgets only within some region</li><li>…</li></ul><p>Please see the demo below to understand what I’m talking about above</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FOd9_HAxBa5A%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DOd9_HAxBa5A&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FOd9_HAxBa5A%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6aeccb77beb51c48beca3c9fce28b51a/href">https://medium.com/media/6aeccb77beb51c48beca3c9fce28b51a/href</a></iframe><p>Of course you can do all this stuff without <em>blueprint mode </em>to see all you real images and colors</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YlIWONRmADLuhkdD4uAPZw.png" /></figure><p>Is it love ♥♥♥? Right now I’m not sure. I understand that it’s only alpha, but let me say some unkind words (with dozen kind words behind it):</p><ul><li>It’s very very slow process and it take a lot of my time to construct smth and see the right result</li><li>I’ve never used <em>Layout Editor</em> to manually drag-and-drop widgets. Every time I just write it directly in <em>XML-file</em> and see the result on the screen. Is it more comfortable right now? I’m not sure.</li><li>It just works incorrectly and there are a lot of cases when preview isn’t updated</li><li>Ok, let’s imagine that everything works fine but if you see <em>XML-file</em>’s code then you will see a bunch of useless code lines that I don’t want to see:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/114986b2f681fb2df7af708b714fc3eb/href">https://medium.com/media/114986b2f681fb2df7af708b714fc3eb/href</a></iframe><ul><li>Also when your layout contains a lot of widgets and you have for instance a <em>MacBook (13&quot;)</em> then forget about attempts to understand “what’s going on?”. Why? See</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*p1H6wBsvMPsvCa0Xlg-svA.png" /></figure><p>Ok, enough. I’m a little bit picky. The truth is the following: this is really cool feature and you definitely should use it!</p><h4>Bottom line</h4><p>Personally IMO I want to continue to work with <em>XML-files</em> directly and create all layouts’ stuff using provided attributes. Sorry but right now such kinda editor it’s not for me due to wasting of time. But it looks really awesome, trust me!</p><p>I will use <strong>ConstraintLayout </strong>because it’s flexible and fast box to place your UI items. But also I don’t want to stop to use other types of layouts like <strong>PercentRelativeLayout</strong>, <strong>FrameLayout</strong> and so on and so forth (at least now). It’s your choice. Just think about questions like “<em>how fast do you want to be?</em>”, “<em>how flexible do you want to be?</em>” and then just use that you want and be happy ( ᐛ )و</p><p>Bye, bye! Cheers! ( ﾟ▽ﾟ)/</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b11b8ef021a4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/do-you-really-like-constraintlayout-lets-see-b11b8ef021a4">Do you really like ConstraintLayout? Let’s see …</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>
        <item>
            <title><![CDATA[If you like Material design then try to materialize smth!]]></title>
            <link>https://medium.com/android-news/if-you-like-material-design-then-try-to-materialize-smth-13ddea87a775?source=rss-5468063993e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/13ddea87a775</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[material-design]]></category>
            <dc:creator><![CDATA[\n Malyshev Yegor \n]]></dc:creator>
            <pubDate>Mon, 08 Feb 2016 20:50:33 GMT</pubDate>
            <atom:updated>2016-02-23T09:17:57.180Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*_X3G9r2zcZJCHzbM_i8Beg.png" /><figcaption><a href="https://play.google.com/store/apps/details?id=org.brainail.EverboxingLexis"><strong>LexisPaper</strong></a></figcaption></figure><p>I know that right now we live <strong>in a very progressive world </strong>where we have an internet access everywhere but it’s not a solution for many cases and we want to use apps in offline mode as much as possible.</p><p>I discover an app that can read some kind of wiki dictionaries (articles) without internet and it’s really cool when you want to find some interesting explanation about some word (phrase) and don’t use any connection to do it. Especially it’s a problem for my country (<a href="https://en.wikipedia.org/wiki/Belarus">Belarus</a>, oh boy …).</p><p>That’s why I decided to <strong>Materialize</strong> the following app <a href="https://play.google.com/store/apps/details?id=itkach.aard2"><strong>Aard2</strong></a><strong>. </strong>Just for fun<strong> (: </strong>Maybe it’s annoying some time to see all apps with some kinda the same design but it’s not bad as you think (IMO).</p><p>I want to present you <a href="https://play.google.com/store/apps/details?id=org.brainail.EverboxingLexis"><strong>LexisPaper</strong></a>! Meow!</p><p>In short I just reimplemented, refactored and redesigned some stuff to make it better. What does it contain?</p><ul><li>Customized <a href="https://www.google.com/design/spec/patterns/navigation-drawer.html"><strong>Navigation view</strong></a></li><li>With some respect to <a href="https://www.google.com/design/spec/layout/metrics-keylines.html">Metric &amp; Keylines</a></li><li>Customized <a href="https://www.google.com/design/spec/components/snackbars-toasts.html"><strong>Snackbar</strong></a> (I call it <em>notices</em>)</li><li>Some <a href="https://www.google.com/design/spec/components/buttons-floating-action-button.html"><strong>FABs</strong></a></li><li>Some <a href="https://www.google.com/design/spec/components/cards.html"><strong>cards</strong></a></li><li>Customized hardy <a href="https://www.google.com/design/spec/components/dialogs.html"><strong>dialogs</strong></a></li><li>Customized <a href="https://www.google.com/design/spec/patterns/settings.html#settings-grouping-settings"><strong>preferences</strong></a></li><li><a href="https://www.google.com/design/spec/components/tabs.html"><strong>Tabs</strong></a></li><li><a href="https://www.google.com/design/spec/components/toolbars.html"><strong>Toolbar</strong></a></li><li><a href="https://developer.chrome.com/multidevice/android/customtabs"><strong>Custom Tabs</strong></a>! I wrote about it <a href="https://medium.com/android-news/android-memo-chrome-custom-tabs-matter-65229aed227#.i191ru4um"><strong>here</strong></a></li><li>So on and so forth</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nu211aUSMsKn5k42f_duIQ.jpeg" /><figcaption><strong>Before</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XDyQjU03VTadP-B4j95G-w.png" /><figcaption><strong>After</strong></figcaption></figure><p>Enjoy! (´・ω・`)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13ddea87a775" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/if-you-like-material-design-then-try-to-materialize-smth-13ddea87a775">If you like Material design then try to materialize smth!</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>
        <item>
            <title><![CDATA[Android memo: Chrome custom Tabs matter]]></title>
            <link>https://medium.com/android-news/android-memo-chrome-custom-tabs-matter-65229aed227?source=rss-5468063993e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/65229aed227</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[chrome-custom-tabs]]></category>
            <dc:creator><![CDATA[\n Malyshev Yegor \n]]></dc:creator>
            <pubDate>Sun, 22 Nov 2015 13:24:33 GMT</pubDate>
            <atom:updated>2016-06-18T08:33:04.469Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UkBK33Qq3aqkwQBBXLu35A.jpeg" /></figure><p>I discovered that <strong>Chrome custom Tabs</strong> really cool thing and if it’s presented on your device (you have suitable browser for it) then you will feel a great experience using it.</p><h4>What are Chrome custom tabs?</h4><p>App developers face a choice when a user taps a <strong>URL</strong> to either launch a browser, or build their own in-app browser using <a href="http://developer.android.com/reference/android/webkit/WebView.html">WebViews</a>.</p><p>Both options present challenges — launching the browser is a heavy context switch that isn’t customizable, while WebViews don’t share state with the browser and add maintenance overhead.</p><p>Chrome custom tabs give apps more control over their web experience, and make transitions between native and web content more seamless without having to resort to a WebView.</p><p>Chrome custom tabs allow an app to customize how Chrome looks and feels. An app can change things like:</p><ul><li><a href="http://developer.android.com/reference/android/widget/Toolbar.html">Toolbar</a> color</li><li><a href="http://developer.android.com/training/material/animations.html">Enter and exit animations</a></li><li>Add custom actions to the Chrome toolbar and <a href="http://developer.android.com/guide/topics/ui/menus.html#PopupMenu">overflow menu</a></li></ul><p>Chrome custom tabs also allow the developer to pre-start Chrome and pre-fetch content for faster loading.</p><h4>Zero step: include Chrome custom Tabs library in your build.gradle file, dependencies section. (I suggest that you use the gradle build system).</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3fac2a084160413bc8a5f5c9b6d3941a/href">https://medium.com/media/3fac2a084160413bc8a5f5c9b6d3941a/href</a></iframe><h4>First step: prepare an empty service used by the custom tab to bind to, raising the application’s importance.</h4><p>The snippet code below shows a simple empty service, nothing special.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da5ea94c5ba0d0834ea1bb7090eecfd6/href">https://medium.com/media/da5ea94c5ba0d0834ea1bb7090eecfd6/href</a></iframe><h4>Second step: goes through all apps that support custom tabs (can handle <a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_VIEW">ACTION_VIEW</a> &amp; have special <strong>warmup service</strong> to warm up the browser process).</h4><p>First of all we try to get the <strong>default package to handle view action</strong>. Then we resolve all apps components that are able to handle <a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsService.html#ACTION_CUSTOM_TABS_CONNECTION">connection to custom tabs</a>.</p><p>Ok and finally we should check some conditions in some special order to choose the best component:</p><ul><li>If no components that can handle both things then we return nothing (null).</li><li>If there is only one suitable component to do it then pick it and return it (and keep it to reuse later and don’t repeat all stuff above).</li><li>If there are several components to do it then we try to check and choose the default handler for such actions (<strong>default package to handle view action</strong>) and if this component can handle URLs correctly (has suitable intent filter, special paths and schemes) then we choose it.</li><li>Otherwise we check four special packages (Chrome packages) and if some of them is presented then we choose it. Right now we should check only the following <strong>Chrome’s packages </strong>using particular order: stable (<em>com.android.chrome</em>), beta (<em>com.chrome.beta</em>), dev (<em>com.chrome.dev</em>), local (<em>com.google.android.apps.chrome</em>).</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40a972baa4607b72c2f99493c73d49fb/href">https://medium.com/media/40a972baa4607b72c2f99493c73d49fb/href</a></iframe><h4>Third step: manage the connection to the <strong>Custom Tabs Service.</strong></h4><p><strong>Steps to bind/unbind to/from custom tabs service:</strong></p><ul><li>Get package name to use</li><li><a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsServiceConnection.html">Create service connection</a> and <a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#bindCustomTabsService%28android.content.Context,%20java.lang.String,%20android.support.customtabs.CustomTabsServiceConnection%29">bind to custom tabs service</a> using it and the found package.</li><li><a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsServiceConnection.html#onCustomTabsServiceConnected%28android.content.ComponentName,%20android.support.customtabs.CustomTabsClient%29">When we are connected</a> then we should keep <a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html">custom tabs client</a> and warm up the browser process. Also after all of that we want to create and keep <a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsSession.html">custom tabs session</a> (we will use the current session later to try to launch url).</li><li>When we are disconnected we just forget our custom tabs client.</li></ul><p><strong>Steps to open URLs</strong>:</p><ul><li>Get package name to use</li><li>If there is a handler then <a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder.html">create</a> a special <a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.html">custom tabs intent</a> and use the found package and the prepared intent together to launch our URLs. Otherwise use your own WebView to display URLs or just open it via view intent through the device’s <strong>browsable applications.</strong></li></ul><p>Please explore the code/snippet below to understand all steps more deeply.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a94d10e6f1759489fa87c0e74a7075e3/href">https://medium.com/media/a94d10e6f1759489fa87c0e74a7075e3/href</a></iframe><h4>Fourth step: build intent and provide via it all necessary options for your needs (main action button, colors, scroll behavior, menu items, …) and then open it.</h4><p>Using the provided builder class (<strong>CustomTabsIntent.Builder</strong>) we can specify a lot of things:</p><ul><li><a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder.html#addMenuItem%28java.lang.String,%20android.app.PendingIntent%29"><strong>addMenuItem</strong></a> (…) — Adds a menu item via label and pending intent to call it on tap.</li><li><a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder.html#enableUrlBarHiding%28%29"><strong>enableUrlBarHiding</strong></a> (…) — Enables the url bar to hide as the user scrolls down on the page.</li><li><a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder.html#setActionButton%28android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean%29"><strong>setActionButton</strong></a> (…) — Sets the action button. It’s like menu item but here we show that this is main action and also in addition we should provide some nice icon to show the action’s purpose.</li><li><a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder.html#setCloseButtonIcon%28android.graphics.Bitmap%29"><strong>setCloseButtonIcon</strong></a> (…) — Specifies a bitmap for close action. It’s useful because we can simulate App’s UP button.</li><li><a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder.html#setExitAnimations%28android.content.Context,%20int,%20int%29"><strong>setExitAnimations</strong></a> (…) — Sets the exit animations.</li><li><a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder.html#setShowTitle%28boolean%29"><strong>setShowTitle</strong></a> (…) — Sets whether the title should be shown in the custom tab.</li><li><a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder.html#setStartAnimations%28android.content.Context,%20int,%20int%29"><strong>setStartAnimations</strong></a> (…) — Sets the start animations.</li><li><a href="http://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder.html#setToolbarColor%28int%29"><strong>setToolbarColor</strong></a> (…) — Sets the toolbar color. It’s a cool place to use primary color or colors that provides <a href="http://developer.android.com/reference/android/support/v7/graphics/Palette.html">Palette</a>.</li><li><strong>…</strong></li></ul><p>Below you will see the code/snippet that demonstrates everything. I used custom tabs on Fragment, but it’s definitely the same as using it on Activity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea7855ccd4cfae15d6c118d876928b53/href">https://medium.com/media/ea7855ccd4cfae15d6c118d876928b53/href</a></iframe><h4>The bottom line (I like it):</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FTOQyDzvhAd4%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DTOQyDzvhAd4%26feature%3Dyoutu.be&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FTOQyDzvhAd4%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1c4a918a93b067dc76b97592be9a63a/href">https://medium.com/media/c1c4a918a93b067dc76b97592be9a63a/href</a></iframe><p>Bye, bye ╭( ･ㅂ･)و ̑̑ ˂ᵒ͜͡ᵏᵎ⁾✩</p><p>BTW! I want to suggest the simplest way to do it. But it’s suitable only if you don’t need some extra features from <strong>Chrome custom Tabs</strong> (<em>warming up</em> for instance). You might want to use it if you just need to open some url somewhere somehow :) On <strong>Google I/O 2016</strong> guys from <em>support team </em>announced a new version of support library: <strong>24.0.0</strong>.</p><p>You should follow two easy steps to use new features from <strong>24.0.0</strong>:</p><pre>// #1. NOTE: IMO its optional, but it really helps to be faster. Warm up default custom tabs service in the background. Call it somewhere here Application#onCreate or Activity#onCreate<br>                                 CustomTabsClient.connectAndInitialize (context, CustomTabsClient.getPackageName (context, null));</pre><pre>// #2. Launch a custom tab using default service. It will open your url instantly. If you want to customize it then reread my post ;) Call it when you want: for instance on some clicks.                                                      <br>                                                                   new CustomTabsIntent.Builder ().build ().launchUrl (activity, Uri.parse (&quot;https://github.com&quot;));</pre><p>Cheers! (╯°□°）╯︵ ┻━┻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65229aed227" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/android-memo-chrome-custom-tabs-matter-65229aed227">Android memo: Chrome custom Tabs matter</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>
        <item>
            <title><![CDATA[My skeleton for Android App | Start Kit (with source code) plus flexible gradle configuration and…]]></title>
            <link>https://medium.com/@brainail/my-skeleton-for-android-app-start-kit-with-source-code-plus-flexible-gradle-configuration-and-95e30c26e788?source=rss-5468063993e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/95e30c26e788</guid>
            <category><![CDATA[sketch]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[\n Malyshev Yegor \n]]></dc:creator>
            <pubDate>Mon, 20 Jul 2015 22:33:54 GMT</pubDate>
            <atom:updated>2016-03-28T07:24:24.389Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>My skeleton for Android App | Start Kit (with source code) plus flexible gradle configuration and so on and so forth. Enjoy!</strong></h4><p>Let’s start from some <a href="https://www.youtube.com/watch?v=AapTDiww_mo"><strong>video showcase</strong></a> and then finish with some source code. It will be very briefly but I think that it’s enough and you can find the full source code on the <a href="https://bitbucket.org/brainail/.everboxing-start-kit"><strong>BitBucket</strong></a>.</p><p>It’s all about Android to start an app from a scratch using <a href="https://www.google.com/design/spec/material-design/introduction.html"><strong>Material design</strong></a> and to have a flexible <a href="https://gradle.org/getting-started-android/"><strong>gradle</strong></a> system to configure <a href="http://developer.android.com/tools/testing/testing_android.html#JUnit"><strong>testing</strong></a>, <a href="https://developer.android.com/tools/building/configuring-gradle.html"><strong>builds</strong></a> and so on and so forth. You’ll find out how to use <a href="http://developer.android.com/tools/testing/testing_android.html#JUnit"><strong>testing</strong></a>, how to <a href="http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Signing-Configurations"><strong>sign</strong></a> you app in a safe way, how to use <a href="http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Lint-support"><strong>lint</strong></a>, how to use <a href="https://en.wikipedia.org/wiki/FindBugs"><strong>findbugs</strong></a>, how to use <a href="https://en.wikipedia.org/wiki/PMD_(software)"><strong>pmd</strong></a> and even more how to use <a href="http://docs.fabric.io/android/"><strong>fabric</strong></a> to catch crashes of you app (also in a safe manner), how to configure <a href="http://developer.android.com/tools/help/proguard.html"><strong>proguard</strong></a>, how to connect to <a href="https://developers.google.com/android/guides/setup"><strong>google play services</strong></a> and even even more how to run it <strong>all together</strong>. Gl &amp; Hf!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FAapTDiww_mo%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DAapTDiww_mo%26feature%3Dyoutu.be&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FAapTDiww_mo%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b052165fb38d6b7a3df348130bd4a628/href">https://medium.com/media/b052165fb38d6b7a3df348130bd4a628/href</a></iframe><p>Play with <a href="https://gradle.org/getting-started-android/"><strong>gradle</strong></a>:</p><ul><li><strong>Checkstyle</strong>: ./gradlew checkstyle</li><li><strong>Lint</strong>: ./gradlew lint</li><li><strong>Findbugs</strong>: ./gradlew findbugs</li><li><strong>Pmd</strong>: ./gradlew pmd</li><li><strong>Analyze code (± lint, findbugs, pmd, checkstyle)</strong>: ./gradlew analyzecode</li><li><strong>Build</strong>: ./gradlew clean assembleDebug{Release}</li><li><strong>Tests</strong>: ./gradlew test</li><li><strong>Show dependencies for configuration</strong>: ./gradlew -q dependencies Everboxing:dependencies — configuration testCompile</li></ul><p>Play with <a href="https://www.google.com/design/spec/patterns/navigation-drawer.html"><strong>Navigation</strong></a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7519eae83d9984c66588c987b2b11c61/href">https://medium.com/media/7519eae83d9984c66588c987b2b11c61/href</a></iframe><p>Play with <a href="http://www.google.com/design/spec/components/snackbars-toasts.html"><strong>snacks/notices/toasts</strong></a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62a325c5775f0673b482367efad5a101/href">https://medium.com/media/62a325c5775f0673b482367efad5a101/href</a></iframe><p>I think it will be more useful to see the entire repository and look around the source code than I will post all interesting parts here and <strong>spoil brevity.</strong></p><p>Thanks for watching! Hah :3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95e30c26e788" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cheat tips: become ADBknowledgeable ୧╏ ՞ _ ՞ ╏୨]]></title>
            <link>https://medium.com/@brainail/cheat-tips-become-as-adbknowledgeable-%E0%AD%A7-%E0%AD%A8-ac4e53804003?source=rss-5468063993e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac4e53804003</guid>
            <category><![CDATA[console]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[adb]]></category>
            <dc:creator><![CDATA[\n Malyshev Yegor \n]]></dc:creator>
            <pubDate>Tue, 14 Jul 2015 08:41:55 GMT</pubDate>
            <atom:updated>2018-08-22T20:10:11.298Z</atom:updated>
            <content:encoded><![CDATA[<p>You won’t see here a cool story about knowledge. Just some tips to be more knowledgeable with <strong>adb tool</strong> in Android☺</p><p><strong>List of attached devices:</strong></p><blockquote><em>adb devices</em></blockquote><p><strong>To do something with some specific device:</strong></p><blockquote><em>adb -s SERIAL_NUMBER …</em></blockquote><p><strong>Install app/apk action (use -r to keep all app’s data):</strong></p><blockquote><em>adb install -r APK_FILE_NAME</em></blockquote><p><strong>Uninstall app/apk action (you can find a app name/package via App Info):</strong></p><blockquote><em>adb uninstall PACKAGE_NAME</em></blockquote><p><strong>Go to the shell !:</strong></p><blockquote><em>adb shell</em></blockquote><p><strong>Current activity on screen:</strong></p><blockquote><em>adb shell dump sys window windows | grep -E ‘mCurrentFocus|mFocusedApp’</em></blockquote><p><strong>All activities, tasks:</strong></p><blockquote><em>adb shell dump sys activity activities</em></blockquote><p><strong>Start some specific activity of your app:</strong></p><blockquote><em>adb shell am start -n YOUR_PACKAGE_NAME/.ACTIVITY_NAME</em></blockquote><blockquote><em>adb shell am start -n YOUR_PACKAGE_NAME/PACKAGE.ACTIVITY_NAME</em></blockquote><p><strong>You can also specify actions to be filter by your intent-filters:</strong></p><blockquote><em>adb shell am start -a com.example.ACTION_NAME -n …</em></blockquote><p><strong>Do you want to see logs (with timestamp)? OK.</strong></p><blockquote><em>adb logcat -v time</em></blockquote><p><strong>Do you want to see logs and filter them by some data? OK.</strong></p><blockquote><em>adb logcat -v time | grep data</em></blockquote><p><strong>Take a screenshot (What did u say?):</strong></p><blockquote><em>adb shell screencap -p | perl -pe </em><strong><em>‘s/\x0D\x0A/\x0A/g’</em></strong><em> &gt; screenshot.png</em></blockquote><p><strong>Record a screencast (copy + delete):</strong></p><blockquote><em>adb shell screenrecord </em>[options] <em>/sdcard/screencast.mp4 — time-limit 21</em></blockquote><blockquote><em>adb pull /sdcard/screencast.mp4</em></blockquote><blockquote><em>adb shell “rm /sdcard/screencast.mp4”</em></blockquote><blockquote><em>[options]</em></blockquote><blockquote><em>— size &lt;WIDTHxHEIGHT&gt; Sets the video size: 1280x720. The default value is the device’s native display resolution (if supported), 1280x720 if not. For best results, use a size supported by your device’s Advanced Video Coding (AVC) encoder.</em></blockquote><blockquote><em>— bit-rate &lt;RATE&gt; Sets the video bit rate for the video, in megabits per second. The default value is 4Mbps. You can increase the bit rate to improve video quality, but doing so results in larger movie files. The following example sets the recording bit rate to 6Mbps:<br>screenrecord</em></blockquote><blockquote><em>— bit-rate 6000000 /sdcard/demo.mp4 — time-limit &lt;TIME&gt; Sets the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).</em></blockquote><blockquote><em>— rotate Rotates the output 90 degrees. This feature is experimental.</em></blockquote><blockquote><em>— verbose Displays log information on the command-line screen. If you do not set this option, the utility does not display any information while running.</em></blockquote><p><strong>Turn the device on or off:</strong></p><blockquote><em>adb shell input keyevent 26</em></blockquote><p><strong>Unlock:</strong></p><blockquote><em>adb shell input keyevent 82</em></blockquote><p><strong>Even more, you can combine it (on + unlock):</strong></p><blockquote><em>adb shell input keyevent 26 82</em></blockquote><p><strong>List of codes for keyevent</strong> (<em>also see additional info</em> <a href="http://developer.android.com/reference/android/view/KeyEvent.html"><strong>here</strong></a>):</p><blockquote><em>0 --&gt; &quot;KEYCODE_UNKNOWN&quot;<br>1 --&gt; &quot;KEYCODE_MENU&quot;<br>2 --&gt; &quot;KEYCODE_SOFT_RIGHT&quot;<br>3 --&gt; &quot;KEYCODE_HOME&quot;<br>4 --&gt; &quot;KEYCODE_BACK&quot;<br>5 --&gt; &quot;KEYCODE_CALL&quot;<br>6 --&gt; &quot;KEYCODE_ENDCALL&quot;<br>7 --&gt; &quot;KEYCODE_0&quot;<br>8 --&gt; &quot;KEYCODE_1&quot;<br>9 --&gt; &quot;KEYCODE_2&quot;<br>10 --&gt; &quot;KEYCODE_3&quot;<br>11 --&gt; &quot;KEYCODE_4&quot;<br>12 --&gt; &quot;KEYCODE_5&quot;<br>13 --&gt; &quot;KEYCODE_6&quot;<br>14 --&gt; &quot;KEYCODE_7&quot;<br>15 --&gt; &quot;KEYCODE_8&quot;<br>16 --&gt; &quot;KEYCODE_9&quot;<br>17 --&gt; &quot;KEYCODE_STAR&quot;<br>18 --&gt; &quot;KEYCODE_POUND&quot;<br>19 --&gt; &quot;KEYCODE_DPAD_UP&quot;<br>20 --&gt; &quot;KEYCODE_DPAD_DOWN&quot;<br>21 --&gt; &quot;KEYCODE_DPAD_LEFT&quot;<br>22 --&gt; &quot;KEYCODE_DPAD_RIGHT&quot;<br>23 --&gt; &quot;KEYCODE_DPAD_CENTER&quot;<br>24 --&gt; &quot;KEYCODE_VOLUME_UP&quot;<br>25 --&gt; &quot;KEYCODE_VOLUME_DOWN&quot;<br>26 --&gt; &quot;KEYCODE_POWER&quot;<br>27 --&gt; &quot;KEYCODE_CAMERA&quot;<br>28 --&gt; &quot;KEYCODE_CLEAR&quot;<br>29 --&gt; &quot;KEYCODE_A&quot;<br>30 --&gt; &quot;KEYCODE_B&quot;<br>31 --&gt; &quot;KEYCODE_C&quot;<br>32 --&gt; &quot;KEYCODE_D&quot;<br>33 --&gt; &quot;KEYCODE_E&quot;<br>34 --&gt; &quot;KEYCODE_F&quot;<br>35 --&gt; &quot;KEYCODE_G&quot;<br>36 --&gt; &quot;KEYCODE_H&quot;<br>37 --&gt; &quot;KEYCODE_I&quot;<br>38 --&gt; &quot;KEYCODE_J&quot;<br>39 --&gt; &quot;KEYCODE_K&quot;<br>40 --&gt; &quot;KEYCODE_L&quot;<br>41 --&gt; &quot;KEYCODE_M&quot;<br>42 --&gt; &quot;KEYCODE_N&quot;<br>43 --&gt; &quot;KEYCODE_O&quot;<br>44 --&gt; &quot;KEYCODE_P&quot;<br>45 --&gt; &quot;KEYCODE_Q&quot;<br>46 --&gt; &quot;KEYCODE_R&quot;<br>47 --&gt; &quot;KEYCODE_S&quot;<br>48 --&gt; &quot;KEYCODE_T&quot;<br>49 --&gt; &quot;KEYCODE_U&quot;<br>50 --&gt; &quot;KEYCODE_V&quot;<br>51 --&gt; &quot;KEYCODE_W&quot;<br>52 --&gt; &quot;KEYCODE_X&quot;<br>53 --&gt; &quot;KEYCODE_Y&quot;<br>54 --&gt; &quot;KEYCODE_Z&quot;<br>55 --&gt; &quot;KEYCODE_COMMA&quot;<br>56 --&gt; &quot;KEYCODE_PERIOD&quot;<br>57 --&gt; &quot;KEYCODE_ALT_LEFT&quot;<br>58 --&gt; &quot;KEYCODE_ALT_RIGHT&quot;<br>59 --&gt; &quot;KEYCODE_SHIFT_LEFT&quot;<br>60 --&gt; &quot;KEYCODE_SHIFT_RIGHT&quot;<br>61 --&gt; &quot;KEYCODE_TAB&quot;<br>62 --&gt; &quot;KEYCODE_SPACE&quot;<br>63 --&gt; &quot;KEYCODE_SYM&quot;<br>64 --&gt; &quot;KEYCODE_EXPLORER&quot;<br>65 --&gt; &quot;KEYCODE_ENVELOPE&quot;<br>66 --&gt; &quot;KEYCODE_ENTER&quot;<br>67 --&gt; &quot;KEYCODE_DEL&quot;<br>68 --&gt; &quot;KEYCODE_GRAVE&quot;<br>69 --&gt; &quot;KEYCODE_MINUS&quot;<br>70 --&gt; &quot;KEYCODE_EQUALS&quot;<br>71 --&gt; &quot;KEYCODE_LEFT_BRACKET&quot;<br>72 --&gt; &quot;KEYCODE_RIGHT_BRACKET&quot;<br>73 --&gt; &quot;KEYCODE_BACKSLASH&quot;<br>74 --&gt; &quot;KEYCODE_SEMICOLON&quot;<br>75 --&gt; &quot;KEYCODE_APOSTROPHE&quot;<br>76 --&gt; &quot;KEYCODE_SLASH&quot;<br>77 --&gt; &quot;KEYCODE_AT&quot;<br>78 --&gt; &quot;KEYCODE_NUM&quot;<br>79 --&gt; &quot;KEYCODE_HEADSETHOOK&quot;<br>80 --&gt; &quot;KEYCODE_FOCUS&quot;<br>81 --&gt; &quot;KEYCODE_PLUS&quot;<br>82 --&gt; &quot;KEYCODE_MENU&quot;<br>83 --&gt; &quot;KEYCODE_NOTIFICATION&quot;<br>84 --&gt; &quot;KEYCODE_SEARCH&quot;<br>85 --&gt; &quot;TAG_LAST_KEYCODE&quot;</em></blockquote><p><strong>If you want to send some text (even if you want to send embedded spaces with the input command, use %s):</strong></p><blockquote><em>adb shell input text ‘This%sis%sSPARTA!’</em></blockquote><p><strong>Print all installed packages:</strong></p><blockquote><em>adb shell pm list packages -f</em></blockquote><p><strong>Clear application data:</strong></p><blockquote><em>adb shell pm clear PACKAGE_NAME</em></blockquote><p><strong>To show the log stream on your command line &amp; filter by tagname:</strong></p><blockquote><em>adb logcat -s TAG_NAME<br>adb logcat -s TAG_NAME_01 TAG_NAME_02 …</em></blockquote><p><strong>To show logs of a specific priority warning and above (for instance :W is warning):</strong></p><blockquote><em>adb logcat “*:PRIORITY”<br>adb logcat “*:W”</em></blockquote><p><strong>Here are the priority levels:</strong></p><blockquote><em>V — Verbose (lowest priority)<br>D — Debug<br>I — Info<br>W — Warning<br>E — Error<br>F — Fatal<br>S — Silent (highest priority, on which nothing is ever printed)</em></blockquote><p><strong>Filter by tagname and priority:</strong></p><blockquote><em>adb logcat -s TAG_NAME:PRIORITY<br>adb logcat -s TAG_NAME_01:PRIORITY TAG_NAME_02:PRIORITY</em></blockquote><p><strong>Use this to clear the buffer to remove any old log data:</strong></p><blockquote><em>adb logcat -c</em></blockquote><p><strong>Toggle Android Emulator 2G network limits over and over</strong> (<strong><em>toggler.sh</em></strong>):</p><blockquote><em>while true<br>do echo “network speed full” | nc localhost 5554 sleep 1 echo “network speed gsm” | nc localhost 5554 sleep 1<br>done</em></blockquote><p><strong>Forwarding ports (to set up arbitrary port forwarding — forwarding of requests on a specific host port to a different port on an emulator/device instance):</strong></p><blockquote><em>adb forward tcp:FROM_LOCAL tcp:TO_REMOTE<br>adb forward tcp:6100 tcp:7100</em></blockquote><p><strong>Port specifications can use these schemes:</strong></p><blockquote><em>tcp: &lt;portnum&gt;<br>local: &lt;UNIX domain socket name&gt;<br>dev: &lt;character device name&gt;<br>jdwp: &lt;pid&gt;</em></blockquote><p><strong>To copy a file or directory (and its sub-directories) from the emulator or device, use:</strong></p><blockquote><em>adb pull REMOTE_PATH LOCAL_PATH</em></blockquote><p><strong>To copy a file or directory (and its sub-directories) to the emulator or device, use:</strong></p><blockquote><em>adb push LOCAL_PATH REMOTE_PATH<br>adb push file.txt /sdcard/file.txt</em></blockquote><p><strong>This command will start the server if the server is off or killed:</strong></p><blockquote><em>adb start-server</em></blockquote><p><strong>This command will close ADB server. Useful if ADB server is acting up or not connecting to any devices:</strong></p><blockquote><em>adb kill-server</em></blockquote><p><strong>To print the adb instance serial number string:</strong></p><blockquote><em>adb get-serialno</em></blockquote><p><strong>This command will mounts the /system/ partition Read/Writable pending the device is allow to:</strong></p><blockquote><em>adb remount</em></blockquote><p><strong>This command will restart ADB with root permissions if the build allows for it:</strong></p><blockquote><em>adb root</em></blockquote><p><strong>This command will restart ADB on device to use USB connection for ADB communication:</strong></p><blockquote><em>adb usb</em></blockquote><p><strong>This command will restart ADB on device to use TCPIP connection for ADB. Standard port is 5555:</strong></p><blockquote><em>adb tcpip PORT</em></blockquote><p><strong>This command will restart your device. If either of the two options (recovery/bootloader) are given, the device will boot into that mode:</strong></p><blockquote><em>adb reboot MODE</em></blockquote><p><strong>To print dumpsys, dumpstate, and logcat data to the screen, for the purposes of bug reporting:</strong></p><blockquote><em>adb bugreport</em></blockquote><p><strong>Start an Activity specified by &lt;INTENT&gt;:</strong></p><blockquote><em>adb shell start &lt;INTENT&gt;</em></blockquote><p><strong>Start the Service specified by &lt;INTENT&gt;:</strong></p><blockquote><em>adb shell startservice &lt;INTENT&gt;</em></blockquote><p><strong>To force stop everything associated with &lt;PACKAGE&gt; (the app’s package name):</strong></p><blockquote><em>adb shell force-stop &lt;PACKAGE&gt;</em></blockquote><p><strong>Kill all processes associated with &lt;PACKAGE&gt; (the app’s package name). This command kills only processes that are safe to kill and that will not impact the user experience:</strong></p><blockquote><em>adb shell kill &lt;PACKAGE&gt;</em></blockquote><p><strong>To kill all background processes:</strong></p><blockquote><em>adb shell kill-all</em></blockquote><p><strong>Issue a broadcast intent:</strong></p><blockquote><em>adb shell broadcast &lt;INTENT&gt;</em></blockquote><p><strong>To start profiler on &lt;PROCESS&gt;, write results to &lt;FILE&gt;:</strong></p><blockquote><em>adb shell profile start &lt;PROCESS&gt; &lt;FILE&gt;</em></blockquote><p><strong>To stop profiler on &lt;PROCESS&gt;:</strong></p><blockquote><em>adb shell profile stop &lt;PROCESS&gt;</em></blockquote><p><strong>To dump the heap of &lt;PROCESS&gt;, write to &lt;FILE&gt; (use -n to dump native heap instead of managed heap):</strong></p><blockquote><em>adb shell dumpheap &lt;PROCESS&gt; &lt;FILE&gt;</em></blockquote><p><strong>To start monitoring for crashes or ANRs:</strong></p><blockquote><em>adb shell monitor</em></blockquote><p><strong>To print the given intent specification as a URI:</strong></p><blockquote><em>adb shell to-uri &lt;INTENT&gt;</em></blockquote><p><strong>To print the given intent specification as an intent (URI):</strong></p><blockquote><em>adb shell to-intent-uri &lt;INTENT&gt;</em></blockquote><p><strong>For activity manager commands that take a &lt;INTENT&gt; argument, you can specify the intent with the following options:</strong></p><blockquote><em>-a &lt;ACTION&gt; Specify the intent action, such as “android.intent.action.VIEW”. You can declare this only once.<br>-d &lt;DATA_URI&gt; Specify the intent data URI, such as “content://contacts/people/1”. You can declare this only once.<br>-t &lt;MIME_TYPE&gt; Specify the intent MIME type, such as “image/png”. You can declare this only once.<br>-c &lt;CATEGORY&gt; Specify an intent category, such as “android.intent.category.APP_CONTACTS”.<br>-n &lt;COMPONENT&gt; Specify the component name with package name prefix to create an explicit intent, such as “com.example.app/.ExampleActivity”.<br>-f &lt;FLAGS&gt; Add flags to the intent, as supported by setFlags(). — esn &lt;EXTRA_KEY&gt; Add a null extra. This option is not supported for URI intents.<br>-e| — es &lt;EXTRA_KEY&gt; &lt;EXTRA_STRING_VALUE&gt; Add string data as a key-value pair. — ez &lt;EXTRA_KEY&gt; &lt;EXTRA_BOOLEAN_VALUE&gt; Add boolean data as a key-value pair. — ei &lt;EXTRA_KEY&gt; &lt;EXTRA_INT_VALUE&gt; Add integer data as a key-value pair. — el &lt;EXTRA_KEY&gt; &lt;EXTRA_LONG_VALUE&gt; Add long data as a key-value pair. — ef &lt;EXTRA_KEY&gt; &lt;EXTRA_FLOAT_VALUE&gt; Add float data as a key-value pair. — eu &lt;EXTRA_KEY&gt; &lt;EXTRA_URI_VALUE&gt; Add URI data as a key-value pair. — ecn &lt;EXTRA_KEY&gt; &lt;EXTRA_COMPONENT_NAME_VALUE&gt; Add a component name, which is converted and passed as a ComponentName object. — eia &lt;EXTRA_KEY&gt; &lt;EXTRA_INT_VALUE&gt;[,&lt;EXTRA_INT_VALUE…] Add an array of integers. — ela &lt;EXTRA_KEY&gt; &lt;EXTRA_LONG_VALUE&gt;[,&lt;EXTRA_LONG_VALUE…] Add an array of longs. — efa &lt;EXTRA_KEY&gt; &lt;EXTRA_FLOAT_VALUE&gt;[,&lt;EXTRA_FLOAT_VALUE…] Add an array of floats. — grant-read-uri-permission Include the flag FLAG_GRANT_READ_URI_PERMISSION. — grant-write-uri-permission Include the flag FLAG_GRANT_WRITE_URI_PERMISSION. — debug-log-resolution Include the flag FLAG_DEBUG_LOG_RESOLUTION. — exclude-stopped-packages Include the flag FLAG_EXCLUDE_STOPPED_PACKAGES. — include-stopped-packages Include the flag FLAG_INCLUDE_STOPPED_PACKAGES. — activity-brought-to-front Include the flag FLAG_ACTIVITY_BROUGHT_TO_FRONT. — activity-clear-top Include the flag FLAG_ACTIVITY_CLEAR_TOP. — activity-clear-when-task-reset Include the flag FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET. — activity-exclude-from-recents Include the flag FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS. — activity-launched-from-history Include the flag FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY. — activity-multiple-task Include the flag FLAG_ACTIVITY_MULTIPLE_TASK. — activity-no-animation Include the flag FLAG_ACTIVITY_NO_ANIMATION. — activity-no-history Include the flag FLAG_ACTIVITY_NO_HISTORY. — activity-no-user-action Include the flag FLAG_ACTIVITY_NO_USER_ACTION. — activity-previous-is-top Include the flag FLAG_ACTIVITY_PREVIOUS_IS_TOP. — activity-reorder-to-front Include the flag FLAG_ACTIVITY_REORDER_TO_FRONT. — activity-reset-task-if-needed Include the flag FLAG_ACTIVITY_RESET_TASK_IF_NEEDED. — activity-single-top Include the flag FLAG_ACTIVITY_SINGLE_TOP. — activity-clear-task Include the flag FLAG_ACTIVITY_CLEAR_TASK. — activity-task-on-home Include the flag FLAG_ACTIVITY_TASK_ON_HOME. — receiver-registered-only Include the flag FLAG_RECEIVER_REGISTERED_ONLY. — receiver-replace-pending Include the flag FLAG_RECEIVER_REPLACE_PENDING. — selector Requires the use of -d and -t options to set the intent data and type.<br>&lt;URI&gt; &lt;COMPONENT&gt; &lt;PACKAGE&gt; You can directly specify a URI, package name, and component name when not qualified by one of the above options. When an argument is unqualified, the tool assumes the argument is a URI if it contains a “:” (colon); it assumes the argument is a component name if it contains a “/” (forward-slash); otherwise it assumes the argument is a package name.</em></blockquote><p><strong>Prints all packages, optionally only those whose package name contains the text in &lt;FILTER&gt;:</strong></p><blockquote><em>Options:</em></blockquote><blockquote><em>-f: See their associated file.<br>-d: Filter to only show disabled packages.<br>-e: Filter to only show enabled packages.<br>-s: Filter to only show system packages.<br>-3: Filter to only show third party packages.<br>-i: See the installer for the packages.<br>-u: Also include uninstalled packages. — user &lt;USER_ID&gt;: The user space to query.</em></blockquote><blockquote><em>adb shell list packages [options] &lt;FILTER&gt;</em></blockquote><p><strong>Prints all known permission groups:</strong></p><blockquote><em>adb shell list permission-groups</em></blockquote><p><strong>Prints all known permissions, optionally only those in &lt;GROUP&gt;.</strong></p><blockquote><em>Options:</em></blockquote><blockquote><em>-g: Organize by group.<br>-f: Print all information.<br>-s: Short summary.<br>-d: Only list dangerous permissions.<br>-u: List only the permissions users will see.</em></blockquote><blockquote><em>adb shell list permissions [options] &lt;GROUP&gt;</em></blockquote><p><strong>List all test packages:</strong></p><blockquote><em>adb shell list instrumentation</em></blockquote><p><strong>Prints all features of the system:</strong></p><blockquote><em>adb shell list features</em></blockquote><p><strong>Prints all the libraries supported by the current device:</strong></p><blockquote><em>adb shell list libraries</em></blockquote><p><strong>Prints all users on the system:</strong></p><blockquote><em>adb shell list users</em></blockquote><p><strong>Print the path to the APK of the given &lt;PACKAGE&gt;:</strong></p><blockquote><em>adb shell path &lt;PACKAGE&gt;</em></blockquote><p><strong>Installs a package (specified by &lt;PATH&gt;) to the system:</strong></p><blockquote><em>Options:</em></blockquote><blockquote><em>-l: Install the package with forward lock.<br>-r: Reinstall an exisiting app, keeping its data.<br>-t: Allow test APKs to be installed.<br>-i &lt;INSTALLER_PACKAGE_NAME&gt;: Specify the installer package name.<br>-s: Install package on the shared mass storage (such as sdcard).<br>-f: Install package on the internal system memory.<br>-d: Allow version code downgrade.</em></blockquote><blockquote><em>adb shell install [options] &lt;PATH&gt;</em></blockquote><p><strong>Removes a package from the system:</strong></p><blockquote><em>Options:</em></blockquote><blockquote><em>-k: Keep the data and cache directories around after package removal.</em></blockquote><blockquote><em>adb shell uninstall [options] &lt;PACKAGE&gt;</em></blockquote><p><strong>Deletes all data associated with a package:</strong></p><blockquote><em>adb shell clear &lt;PACKAGE&gt;</em></blockquote><p><strong>Enable/Disable the given package or component (written as “package/class”):</strong></p><blockquote><em>adb shell enable/disable &lt;PACKAGE_OR_COMPONENT&gt;</em></blockquote><p><strong>Grant/Revoke permissions to applications. Only optional permissions the application has declared can be granted/revoked:</strong></p><blockquote><em>adb shell grant/revoke &lt;PACKAGE_PERMISSION&gt;</em></blockquote><p><strong>Changes the default install location. Location values:<br>0: Auto — Let system decide the best location.<br>1: Internal — install on internal device storage.<br>2: External — install on external media.</strong></p><blockquote><em>adb shell set-install-location &lt;LOCATION&gt;</em></blockquote><p><strong>Returns the current install location. Return values:<br>0 [auto]: Lets system decide the best location<br>1 [internal]: Installs on internal device storage<br>2 [external]: Installs on external media</strong></p><blockquote><em>adb shell get-install-location</em></blockquote><p><strong>Trim cache files to reach the given free space:</strong></p><blockquote><em>adb shell trim-caches &lt;DESIRED_FREE_SPACE&gt;</em></blockquote><p><strong>Create a new user with the given &lt;USER_NAME&gt;, printing the new user identifier of the user:</strong></p><blockquote><em>adb shell create-user &lt;USER_NAME&gt;</em></blockquote><p><strong>Remove the user with the given &lt;USER_IDENTIFIER&gt;, deleting all data associated with that user:</strong></p><blockquote><em>adb shell remove-user &lt;USER_ID&gt;</em></blockquote><p><strong>Prints the maximum number of users supported by the device:</strong></p><blockquote><em>adb shell get-max-users</em></blockquote><h4>For a list of all the available shell programs, use the following command:</h4><blockquote><strong><em>adb shell ls /system/bin</em></strong></blockquote><p>OK, that’s it for today. See ya &amp; gl &amp; hf!（・∀・）</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac4e53804003" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>