<?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[WiseLTeach - Medium]]></title>
        <description><![CDATA[Personalized digital learning solutions that provides assistance to students and teachers. We also publish blogs related to technology mainly in the field of Android. - Medium]]></description>
        <link>https://medium.com/wiselteach?source=rss----6e3d73bea4a0---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>WiseLTeach - Medium</title>
            <link>https://medium.com/wiselteach?source=rss----6e3d73bea4a0---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 05:59:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/wiselteach" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Google I/O 2017- AI First (Part-2)]]></title>
            <link>https://medium.com/wiselteach/google-i-o-2017-ai-first-part-2-1027e0147b3d?source=rss----6e3d73bea4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/1027e0147b3d</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[google-io-2017]]></category>
            <dc:creator><![CDATA[Sandip Ravaliya]]></dc:creator>
            <pubDate>Tue, 23 May 2017 06:43:35 GMT</pubDate>
            <atom:updated>2017-05-24T16:09:25.008Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xpYtAlLJN4KNwr2ATZPo2w.png" /><figcaption>Google I/O 2017</figcaption></figure><p>This blog is about the announcements made at Google I/O 2017. The part-1 of this blog is available here- <a href="https://medium.com/wiselteach/google-i-o-2017-ai-first-part-1-3b206dc57c53"><strong>Google I/O 2017 Part-1.</strong></a></p><blockquote><a href="https://photos.google.com/"><strong><em>Google Photos</em></strong></a></blockquote><p><em>1. Suggested Sharing</em></p><p>Google is now taking care of users’ photos more than users. With this new feature, Google Photos will now provide personal suggestions to users to share photos based on people in the photos and personal sharing habits of user. Users would also be able to see their Google Photos sharing activities.</p><p>Google Photos will even send SMS/email to anyone who doesn’t have the Google Photos App, making everyone to view and save photos even if they don’t have Google Photos account.</p><p><em>2. Shared Library</em></p><p>Users can share their whole/selective library with important persons like close friends or family members based on personal preferences like date, people, etc.</p><p><em>3. Photo Books</em></p><p>The users will have option to choose for Soft Cover or Hard Cover (Paid Services in US for now). After selecting one of which, the user can upload his favorite photos or lot of photos and Google Photos with help of Machine Learning will sort out best photos for user and prompt as suggestion.</p><p>Moreover, future release of Google Lens on Google Photos to help user take actions on photos was also announced. Users can take photos and look later for more about things in that photo. Information about buildings, landmarks, things or relevant people, calling on number directly from photos and such more capabilities are expected to be delivered soon.</p><blockquote><a href="https://vr.google.com/"><strong><em>Virtual Reality</em></strong></a></blockquote><p>Google is now working with Qualcomm to create blueprints for standalone VR headset. They also mentioned about Google working with VR leaders like HTC and Lenovo to create these standalone VR devices which are expected to be deployed in late 2017.</p><blockquote><strong><em>Augmented Reality</em></strong></blockquote><p>Use of <a href="https://get.google.com/tango/">Tango</a> and <a href="https://www.google.co.in/maps">Google Maps</a> together was announced to utilize Augmented Reality in its most powerful state (i.e. when AR is tightly coupled with real world) to create Google Virtual Positioning Service (VPS). VPS is sort of like GPS but instead of communicating with satellites for position, the phone will look for distinct visual features in environment and it triangulates with those. This technology can be of great help to visually impaired people. With VPS, if you want to buy something specific from supermarket then through GPS you can go to the supermarket location and with VPS you actually locate the item inside the supermarket.</p><blockquote><a href="http://android-developers.googleblog.com/2017/05/whats-new-in-android-o-developer.html"><strong><em>Android O Developer Preview 2</em></strong></a></blockquote><p>Get a look at the next release of Android O focused on fluid experiences that make Android even more useful, and our efforts to optimize battery life, startup time, graphic rendering time, and stability. Early adopters can opt in to the Android O Beta Program at <a href="http://android.com/beta">android.com/beta</a> and run Android O now.</p><blockquote><a href="https://android-developers.googleblog.com/2017/05/android-announces-support-for-kotlin.html"><strong><em>Kotlin</em></strong></a></blockquote><p>Google is now officially supporting the Kotlin programming language, in addition to the Java language and C++ on Android Studio. Kotlin is a statically-typed programming language that runs on the Java Virtual Machine and also can be compiled to JavaScript source code. Kotlin is a brilliantly designed, mature, production-ready language that we believe will make Android development faster and more fun.</p><blockquote><a href="https://android-developers.googleblog.com/2017/05/whats-new-in-android-o-developer.html"><strong><em>Android Go</em></strong></a></blockquote><p>Google is optimizing OS on entry-level devices with RAM less than 1GB. Google is also redesigning the Google apps like YouTube, Chrome, etc. to use less memory, storage, less start-up time and less mobile data.</p><p>Apart from these focus points, Google announced tons of new features and changes on different technical projects and they all mainly aim towards one single point <strong><em>organizing the world’s Information for everyone with deep computer science.</em></strong></p><p>Mark ❤ if you liked this blog and follow us on medium to get updates about our future blogs.</p><p>#AndroidMonk #<a href="http://wiselteach.com/">WiseLTeach</a> #<a href="http://wiselteach.com/">WiseL</a></p><p><a href="http://wiselteach.com/">http://wiselteach.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1027e0147b3d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wiselteach/google-i-o-2017-ai-first-part-2-1027e0147b3d">Google I/O 2017- AI First (Part-2)</a> was originally published in <a href="https://medium.com/wiselteach">WiseLTeach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google I/O 2017- AI First (Part-1)]]></title>
            <link>https://medium.com/wiselteach/google-i-o-2017-ai-first-part-1-3b206dc57c53?source=rss----6e3d73bea4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/3b206dc57c53</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[google-io-2017]]></category>
            <dc:creator><![CDATA[Sandip Ravaliya]]></dc:creator>
            <pubDate>Sat, 20 May 2017 11:40:59 GMT</pubDate>
            <atom:updated>2017-05-24T16:08:25.330Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xpYtAlLJN4KNwr2ATZPo2w.png" /><figcaption>Google I/O 2017</figcaption></figure><blockquote><strong><em>About Google I/O</em></strong></blockquote><p>Google I/O is annual developer conference by Google to showcase technical products related to building web, mobile, and enterprise applications with Google, open source projects and much more.</p><p>Google I/O 2017 was mainly focused on taking Machine Learning and Artificial Intelligence to next level with the motive of <strong>Mobile First to AI First.</strong></p><p>Google’s CEO, Sundar Pichai, expressed Google’s determination and efforts to take ML and AI to next level for solving user problems and improving the user experience with Google Products.</p><p>The modus operandi of communication with devices via touch is now getting older with evolution of technology in Speech Recognition and Image/Video Recognition. The Word Error Rate has come down to 4.9% from 8.5% in July 2016. Furthermore, the Vision Error Rate for Algorithms has already gone below Human Vision Error Rate in 2016.</p><p>Sundar Pichai also announced to avail capability of obstruction removal from pictures soon (an image of a child playing baseball behind chain wired fence was used to illustrate, in which the obstructing fence was removed to get a clear photo of the child with bat).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*7iJedyRHnOhZPSoYO2gkgQ.gif" /></figure><blockquote><a href="https://cloud.google.com/tpu/"><strong><em>Cloud Tensor Processing Units (Cloud TPUs)</em></strong></a></blockquote><p>The need of remodeling computational architecture was felt to cope with the evolving Machine Learning and Artificial Intelligence world. Therefore, Google have built the AI First Data centers from ground up.</p><p>Machine Learning has two components — Training and Inferences. Last year’s TPUs were optimized only for Inference processes while the newly announced next Generation TPUs designed for AI First Data Centers are optimized for computationally intensive processes of Training also. Google is bringing these next Generation TPUs through Google Cloud Platform and hence, the name Cloud TPU.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*OKxg6tWcSOfT713AeV7aLw.png" /><figcaption>ML Training and Inference</figcaption></figure><blockquote><a href="https://google.ai/"><strong><em>Google.ai</em></strong></a><strong><em> — </em></strong>Bringing AI efforts at Google together for everyone</blockquote><p>Google.ai would be focusing on research, tools (<a href="https://www.tensorflow.org/"><strong>TensorFlow</strong></a> and <a href="https://cloud.google.com/tpu/"><strong>Cloud TPUs</strong></a><strong>)</strong> and applied AI.</p><p>To help developers throughout world to learn machine learning, the Google developed AutoML. AutoML basically is making neural networks to learn how to make neural networks which is finally expected to result into better optimized neural networks using reinforcement learning approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*jiwcpi15_U6bfC-TjeSobA.png" /><figcaption>AutoML</figcaption></figure><blockquote><a href="https://assistant.google.com/"><strong><em>Google Assistant</em></strong></a></blockquote><p><strong>Google Assistant</strong> is an intelligent personal <strong>assistant</strong> developed by <strong>Google</strong> and announced at <strong>Google</strong> I/O in May 2016. Within 1 year of release , it has received so much traction that it is available on 100M devices now. Assistant is expected to communicate in natural languages rather than just keywords and provide different responses to different family members by utilizing the strengths of Google in Speech Recognition, Natural Language understanding and Contextual Meaning.</p><p>Furthermore, Google Lens will be soon introduced to Assistant for Visual Responses. It will enable to users to communicate with Assistant through images too. The translator will help to tackle language barrier and Assistant will help to suggest relevant responses with the help of Google Lens. The Illustrations of image suggestion from assistant based on photo of a Japanese Dish written in Japanese and suggestions for listening to band music, buying tickets for that band concert or setting reminder for that event in calendar came up on screen when Google Lens was pointed at venues marquee were also made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*jqNQsIrvTk9RwqxbHzDMow.png" /><figcaption>Google Assistant with Google Lens</figcaption></figure><p>The Google plans to increase availability of Assistant on devices other than Android like TVs and car systems. The new Google Assistant SDK will allow any device manufacturers to build Assistant in any product.</p><p>The Assistant was officially announced to be available on <strong>iPhone</strong>.</p><p>The Google Assistant would be rolling out in French, German, Brazilian, Portuguese and Japanese starting from this summer.</p><blockquote><a href="https://developers.google.com/actions/"><strong><em>Actions on Google</em></strong></a></blockquote><p>Actions on Google is now available on Android and iPhone. The intention of Google is to provide Assistant to everyone everywhere by opening the Assistant for third party developers to build helpful integration. The announcement of support for transactions on Actions on Google was cheered a lot. You can now order a Pizza with complete payment process with Google Assistant with just 1 touch for payment verification.</p><p>Actions on Google will also be available on Google Home which makes it possible to lock front door, start your TV, control lights and control range of home appliances because of 70+ smart home partners like LG, TP-Link, Stringify and so on. With advancements at such level in future everyone will control electronic devices simply via voice commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*RT9ZujxZmfh6mwpL5lUzzA.png" /></figure><blockquote><a href="https://madeby.google.com/home/"><strong><em>Google Home</em></strong></a></blockquote><p>Four new announcements regarding Google Home –</p><p><em>1. Support for Proactive</em></p><p>The Google Home would now also take care of other minor things relevant to our daily life. It will now communicate expected traffic delays so we can make it to events on time, help with reminders, notify flight status changes. With multiple user support, we can also control the type of notifications we want.</p><p><em>2. Support for Hands-Free calling on Google Home in US and Canada</em></p><p>No extra setup is required. The Google Home will call anyone from users’ contacts at voice command. It will also provide personalized experience based on the voice of person. Currently the Google Home would be using a private number, but the option is given to users to tie-up their personal number.</p><p>3. <em>Music T.V. Support</em></p><p>Spotify adding free music service in addition to their subscription service. The Google Home will also support SoundCloud and Deezer along with preexisting music services like YouTube Music, Google Play Music, Pandora, iHeart Radio and others. To ease the connectivity of Google Home, Google is adding Bluetooth support to all Google Home devices so user can play audio from any iOS and Android device.</p><p>Furthermore, Google have now more additional partners (like HBO NOW) to provide favorite entertainment on TV using Google Home.</p><p><em>4. Support for Visual Responses With Google Home</em></p><p>Chromecasts are updated to show visual responses on TV when asked for help from Google Home. Users will be able to see calendars, weather, favorite videos, video suggestions and much more. And obviously this all is personalized based on voice just like in Hands-Free Calling.</p><p>This blog is a two part series. <a href="https://medium.com/wiselteach/google-i-o-2017-ai-first-part-2-1027e0147b3d">Part 2 link</a>.</p><p>Mark ❤ if you liked this blog and follow us on medium to get updates about our future blogs.</p><p>#AndroidMonk #<a href="http://wiselteach.com/">WiseLTeach</a> #<a href="http://wiselteach.com/">WiseL</a></p><p><a href="http://wiselteach.com/">http://wiselteach.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b206dc57c53" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wiselteach/google-i-o-2017-ai-first-part-1-3b206dc57c53">Google I/O 2017- AI First (Part-1)</a> was originally published in <a href="https://medium.com/wiselteach">WiseLTeach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Activity Back Stack and Launch Mode Part -2]]></title>
            <link>https://medium.com/wiselteach/activity-back-stack-and-launch-mode-part-2-e715c724f7cf?source=rss----6e3d73bea4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/e715c724f7cf</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[backstack]]></category>
            <category><![CDATA[launch-mode]]></category>
            <dc:creator><![CDATA[Raj Suvariya]]></dc:creator>
            <pubDate>Tue, 18 Apr 2017 14:30:14 GMT</pubDate>
            <atom:updated>2017-08-28T17:04:22.607Z</atom:updated>
            <content:encoded><![CDATA[<p>In the first part we learned about activity backstack and two launch modes of Activity. If you haven’t read the first part then do it now and come back when you are done.</p><p><a href="https://medium.com/wiselteach/activity-back-stack-and-launch-mode-part-1-693130682120">Activity Back Stack and Launch Mode Part -1</a></p><p>In this second part we will learn about two more Activity launchmodes : SingleTask and SingleInstance.</p><blockquote>SingleTask</blockquote><p><em>Definition as per Android Docs:<br>“</em>The system creates the activity at the root of a new task and routes the intent to it. However, if an instance of the activity already exists, the system routes the intent to existing instance through a call to its <a href="https://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a> method, rather than creating a new one.”</p><p>What does it mean is only one instance of any activity can exist through all the tasks of the application. If there is already one instance sitting on back stack of any task inside the application and we call startActivity() then all the activities above that instance from the particular task’s backstack will be removed and that task and the activity instance will become visible on the screen.</p><p>For ex.<br>Suppose, there are 4 activities A,B,C and D. C has launchmode SingleTask and the present application backstack is shown at top of the image. Now if we call startActivity(c) then the backstack would became like shown at bottom of the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*flh5KQBitMQHtPLa2roqRA.jpeg" /></figure><blockquote><strong>Note: In the Android docs definition it is mentioned “The system creates the activity at the root of a new task and routes the intent to it”.</strong> However this holds only true when the activity having launchmode as SingleTask also has different taskAffinity then application. If it has the taskAffinity matching any other task inside the application then the new instance will be pushed on the top of the back stack as usual.</blockquote><p>You might have question that “How to change the content from the previous instance?”. Well, you can override the <a href="https://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a> method of the Activity to get new intent and update the information on the screen.</p><blockquote>SingleInstance</blockquote><p><em>Definition as per Android Docs:<br>“</em>Same as “singleTask&quot;, except that the system doesn&#39;t launch any other activities into the task holding the instance. The activity is always the single and only member of its task”.</p><p>It’s pretty clear from the definition itself that it is just like the SingleTask except the activity will be created as the root of the new task regardless of the taskAffinity and that task cannot contain any more activity instance. So the task will contain only one activity instance with launchmode as SingleInstance.</p><p>If we navigate to any other activity from the SingleInstance activity it takes us back to previous task and performs the new activity creation as per it’s launch mode on that task.</p><p>Also, in the case of SingleInstance even if there are more than one task we can only see one instance in recent apps.</p><p>Here is the comparison of all the launchmodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*N2jfgErutZerHpu1Dq9aKg.gif" /></figure><p>If you want to play around by changing the launchmodes of the activities you can get the starter code here.</p><p><a href="https://github.com/AnilDeshpande/ActivityLauchModesDemo">AnilDeshpande/ActivityLauchModesDemo</a></p><p>If you like the blog please mark ❤ and also share it with your fellow developer. Also subscribe to our newsletter to get notifications about ourupcoming blogs.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F2acca1%3Fas_embed%3Dtrue&amp;url=https%3A%2F%2Fupscri.be%2F2acca1%2F&amp;image=https%3A%2F%2Fupscri.be%2Fmedia%2Fform.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d35b01592f932f0fc2b1756c210d0a1/href">https://medium.com/media/0d35b01592f932f0fc2b1756c210d0a1/href</a></iframe><p><a href="http://www.wiselteach.com/">www.wiselteach.com</a></p><p>#AndroidMonk</p><p>#WiseL #WiseLTeach</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e715c724f7cf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wiselteach/activity-back-stack-and-launch-mode-part-2-e715c724f7cf">Activity Back Stack and Launch Mode Part -2</a> was originally published in <a href="https://medium.com/wiselteach">WiseLTeach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Firebase JobDispatcher @AndroidMonk]]></title>
            <link>https://medium.com/wiselteach/firebase-jobdispatcher-androidmonk-3e6d729ed9ce?source=rss----6e3d73bea4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/3e6d729ed9ce</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[services]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Rajat Talesra]]></dc:creator>
            <pubDate>Mon, 10 Apr 2017 19:27:37 GMT</pubDate>
            <atom:updated>2017-04-10T19:27:36.961Z</atom:updated>
            <content:encoded><![CDATA[<p>The Firebase JobDispatcher is a library for scheduling background jobs in your Android app. It provides a <a href="https://developer.android.com/reference/android/app/job/JobScheduler.html">JobScheduler</a>- compatible API that works on all recent versions of Android (API level 9+) that have Google Play services installed.</p><blockquote><strong><em>Why use Firebase JobDispatcher ?</em></strong></blockquote><p>Running your code in background using services, alarm manager and broadcast receiver is an expensive task and it becomes more expensive from battery and RAM perspective when most of the apps in your mobile does that. So to overcome these issues JobScheduler came into picture which is an API to schedule and manage all your jobs in background easily. But this API runs on API 21+. So Firebase JobDispatcher came which supports all API’s (Min API 9).</p><blockquote><strong><em>Setting up the dependency</em></strong></blockquote><p>To use Firebase JobDispatcher in your code you will need to add dependency to your build.grade (Module app) file.</p><p>If you do not have <a href="https://developers.google.com/cloud-messaging/">com.google.android.gms:play-services-gcm</a> in your dependency, add this:</p><pre>compile &#39;com.firebase:firebase-jobdispatcher:0.6.0&#39;</pre><p>otherwise,</p><pre>compile &#39;com.firebase:firebase-jobdispatcher-with-gcm-dep:0.6.0&#39;</pre><p>Check for latest version from <a href="https://github.com/firebase/firebase-jobdispatcher-android">here</a>.</p><blockquote><strong><em>Create your own JobService</em></strong></blockquote><pre><strong>import </strong>android.util.Log;<br><br><strong>import </strong>com.firebase.jobdispatcher.JobParameters;<br><strong>import </strong>com.firebase.jobdispatcher.JobService;<br><br><em>/**<br> * Created by rajat4914 on 01/04/17.<br> */<br><br></em><strong>public class </strong>ScheduledJobService <strong>extends </strong>JobService {<br><br>    <strong>private static final </strong>String <strong><em>TAG </em></strong>= ScheduledJobService.<strong>class</strong>.getSimpleName();<br><br>    @Override<br>    <strong>public boolean </strong>onStartJob(<strong>final </strong>JobParameters params) {<br>        <em>//Offloading work to a new thread.<br>        </em><strong>new </strong>Thread(<strong>new </strong>Runnable() {<br>            @Override<br>            <strong>public void </strong>run() {<br>                codeYouWantToRun(params);<br>            }<br>        }).start();<br><br>        <strong>return true</strong>;<br>    }<br><br>    @Override<br>    <strong>public boolean </strong>onStopJob(JobParameters params) {<br>        <strong>return false</strong>;<br>    }<br><br>    <strong>public void </strong>codeYouWantToRun(<strong>final </strong>JobParameters parameters) {<br>        <strong>try </strong>{<br><br>            Log.<em>d</em>(<strong><em>TAG</em></strong>, <strong>&quot;completeJob: &quot; </strong>+ <strong>&quot;jobStarted&quot;</strong>);<br>            <em>//This task takes 2 seconds to complete.<br>            </em>Thread.<em>sleep</em>(2000);<br><br>            Log.<em>d</em>(<strong><em>TAG</em></strong>, <strong>&quot;completeJob: &quot; </strong>+ <strong>&quot;jobFinished&quot;</strong>);<br>        } <strong>catch </strong>(InterruptedException e) {<br>            e.printStackTrace();<br>        } <strong>finally </strong>{<br>            <em>//Tell the framework that the job has completed and doesnot needs to be reschedule<br>            </em>jobFinished(parameters, <strong>true</strong>);<br>        }<br>    }<br>}</pre><blockquote><strong><em>Using Firebase JobScheculer</em></strong></blockquote><pre><strong>import </strong>android.content.Context;<br><strong>import </strong>android.support.v7.app.AppCompatActivity;<br><strong>import </strong>android.os.Bundle;<br><br><strong>import </strong>com.firebase.jobdispatcher.Constraint;<br><strong>import </strong>com.firebase.jobdispatcher.FirebaseJobDispatcher;<br><strong>import </strong>com.firebase.jobdispatcher.GooglePlayDriver;<br><strong>import </strong>com.firebase.jobdispatcher.Job;<br><strong>import </strong>com.firebase.jobdispatcher.Lifetime;<br><strong>import </strong>com.firebase.jobdispatcher.RetryStrategy;<br><strong>import </strong>com.firebase.jobdispatcher.Trigger;<br><br><strong>public class </strong>MainActivity <strong>extends </strong>AppCompatActivity {<br><br>    @Override<br>    <strong>protected void </strong>onCreate(Bundle savedInstanceState) {<br>        <strong>super</strong>.onCreate(savedInstanceState);<br>        setContentView(R.layout.<strong><em>activity_main</em></strong>);<br><br>        <em>scheduleJob</em>(<strong>this</strong>);<br>    }<br><br>    <strong>public static void </strong>scheduleJob(Context context) {<br>        <em>//creating new firebase job dispatcher<br>        </em>FirebaseJobDispatcher dispatcher = <strong>new </strong>FirebaseJobDispatcher(<strong>new </strong>GooglePlayDriver(context));<br>        <em>//creating new job and adding it with dispatcher<br>        </em>Job job = <em>createJob</em>(dispatcher);<br>        dispatcher.mustSchedule(job);<br>    }<br><br>    <strong>public static </strong>Job createJob(FirebaseJobDispatcher dispatcher){<br><br>        Job job = dispatcher.newJobBuilder()<br>                <em>//persist the task across boots<br>                </em>.setLifetime(Lifetime.<strong><em>FOREVER</em></strong>)<br>                <em>//.setLifetime(Lifetime.UNTIL_NEXT_BOOT)<br>                //call this service when the criteria are met.<br>                </em>.setService(ScheduledJobService.<strong>class</strong>)<br>                <em>//unique id of the task<br>                </em>.setTag(<strong>&quot;UniqueTagForYourJob&quot;</strong>)<br>                <em>//don&#39;t overwrite an existing job with the same tag<br>                </em>.setReplaceCurrent(<strong>false</strong>)<br>                <em>// We are mentioning that the job is periodic.<br>                </em>.setRecurring(<strong>true</strong>)<br>                <em>// Run between 30 - 60 seconds from now.<br>                </em>.setTrigger(Trigger.<em>executionWindow</em>(30, 60))<br>                <em>// retry with exponential backoff<br>                </em>.setRetryStrategy(RetryStrategy.<strong><em>DEFAULT_LINEAR</em></strong>)<br>                <em>//.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)<br>                //Run this job only when the network is available.<br>                </em>.setConstraints(Constraint.<strong><em>ON_ANY_NETWORK</em></strong>, Constraint.<strong><em>DEVICE_CHARGING</em></strong>)<br>                .build();<br>        <strong>return </strong>job;<br>    }<br><br>    <strong>public static </strong>Job updateJob(FirebaseJobDispatcher dispatcher) {<br>        Job newJob = dispatcher.newJobBuilder()<br>                <em>//update if any task with the given tag exists.<br>                </em>.setReplaceCurrent(<strong>true</strong>)<br>                <em>//Integrate the job you want to start.<br>                </em>.setService(ScheduledJobService.<strong>class</strong>)<br>                .setTag(<strong>&quot;UniqueTagForYourJob&quot;</strong>)<br>                <em>// Run between 30 - 60 seconds from now.<br>                </em>.setTrigger(Trigger.<em>executionWindow</em>(30, 60))<br>                .build();<br>        <strong>return </strong>newJob;<br>    }<br><br>    <strong>public void </strong>cancelJob(Context context){<br><br>        FirebaseJobDispatcher dispatcher = <strong>new </strong>FirebaseJobDispatcher(<strong>new </strong>GooglePlayDriver(context));<br>        <em>//Cancel all the jobs for this package<br>        </em>dispatcher.cancelAll();<br>        <em>// Cancel the job for this tag<br>        </em>dispatcher.cancel(<strong>&quot;UniqueTagForYourJob&quot;</strong>);<br><br>    }<br>}</pre><p>If you run this code and fulfill all the constraint conditions you will see you will see 2 logs with time difference of 2000 ms and repeating themselves after every 30–60 secs. And best part is this works even if your app is closed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-YjmcIKhyQrH7_5zhjuK-g.png" /><figcaption>Notice the time in logcat</figcaption></figure><p><a href="https://github.com/rt4914/FirebaseDemos/tree/master/FirebaseJobDispatcher"><em>GitHub Link of the code.</em></a></p><p>Please mark ❤ if you like the blog. In case if you find any mistake please mention that in comment. Stay tuned for more tech blogs.</p><p><a href="http://www.wiselteach.com/">www.wiselteach.com</a></p><p>#AndroidMonk</p><p>#WiseL #WiseLTeach</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e6d729ed9ce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wiselteach/firebase-jobdispatcher-androidmonk-3e6d729ed9ce">Firebase JobDispatcher @AndroidMonk</a> was originally published in <a href="https://medium.com/wiselteach">WiseLTeach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Activity Back Stack and Launch Mode Part -1]]></title>
            <link>https://medium.com/wiselteach/activity-back-stack-and-launch-mode-part-1-693130682120?source=rss----6e3d73bea4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/693130682120</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[backstack]]></category>
            <category><![CDATA[launch-mode]]></category>
            <dc:creator><![CDATA[Raj Suvariya]]></dc:creator>
            <pubDate>Thu, 06 Apr 2017 19:13:38 GMT</pubDate>
            <atom:updated>2017-07-27T14:11:36.823Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wondered what happens to the current activity when you navigate to some other activity by taping some view on the screen? When you press back button how suddenly the same activity comes in font of you? If yes, then you are at the right place to get the answer about these kind of questions. In this blog we will learn about the activity back stack and launch mode of the activity. The blog is divided into 2 parts.</p><p><strong>Knowledge before you read this blog<br></strong>Every application has one or more <strong><em>tasks</em></strong>. Each task is differentiated by the <strong><em>task affinity</em></strong> which is unique for every task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JA0wRAhkhdzMQgQXHIvbQQ.jpeg" /></figure><p>Application by default has only one task with task affinity equal to package name which can be found in androidmanifest.xml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/0*LFRHIJSSA3ndcFwU.jpg" /></figure><p>To see, how many tasks a application has, you can just open recent-apps of your device and just count the number of instances of the same app, that is the number of tasks the app has.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*Qy6zmmbUF9HFbrM5HsrWdg.png" /></figure><blockquote><strong>Note:</strong> Generally, there will be only one task in your application, and which is the best way of writing your application. You should only create more than one task when it is exceptionally necessary. Like payment gateway page, which you want to keep unaffected by other tasks.</blockquote><p><strong>Activity Back Stack<br></strong>The name itself suggest that it has something to do with stack of activities. As we discussed above every activity has either one or more tasks. For each task there is exactly one activity back stack. The topmost activity on the task’s back stack is visible on the screen. Usually, when the app launches the app has one task with just one activity (MainActivity) on it’s backstack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PmUOlz7C5ViLk__6cBjHtA.jpeg" /></figure><p>Whenever, the user navigates from one activity to another the new activity is pushed on the top of the visible task’s back stack and it gets visible to the user, hiding the previous activity’s instance underneath. When user presses back the topmost activity is popped from the visible task’s backstack and the next activity in that stack gets visible on the screen.</p><p>This isn’t just limited to activities, even fragments can be pushed to the backstack. While navigating away from the fragment you can just add</p><pre>fragment_transaction.addBackStack();</pre><p>so when you press back the previous fragment gets visible on the screen.</p><p><strong>Note: </strong>I have used “visible task” term in above discussion. What it means is that there might be lot of task but you can see only one on the screen so the one which is being showed to you is visible task.</p><p><strong>Launch Modes<br></strong>Again name itself suggest that it has something to do with how activity gets launched when we call startActivity(intent) or similar functions. There are basically four type of the launch modes.</p><ol><li>Standard</li><li>SingleTop</li><li>Single Task</li><li>Single Instance</li></ol><blockquote>Standard</blockquote><p><em>Definition as per Android Docs:<br>“The system always creates a new instance of the activity in the target task and routes the intent to it.”</em></p><p>Standard launch mode is default in all the activities you create in your android application. In this launch mode no matter what is there in activity back stack the new instance of the new activity gets created when we pass the intent of the new activity.</p><p>For example: Suppose you have very simple app with just one activity named MainActivity and only one button on the main activity. Now if you call start activity with intent of MainActivity on click of the button then it will launch the new instance of same activity again and the current instance will go to back stack. If you click the button 10 times then there will be 10 instances of the activity in the back stack. So you need to press back 10 times to get out of your application.</p><blockquote>SingleTop</blockquote><p><em>Definition as per Android Docs:<br>“</em>If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance through a call to its <a href="https://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a> method, rather than creating a new instance of the activity.<em>”</em></p><p>Which means that if we call startActivity with the intent of same activity which is on the top of back stack then the new instance will not be created rather the intent will be passed to activity via a method <a href="https://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)">onNewIntent()</a>.</p><p>Taking the same example as above: Suppose you have very simple app with just one activity named MainActivity and only one button on the main activity. Now if the launch mode of the main activity is single top then if you click on the button which call startActivity with the intent of MainActivity then also it won’t launch new instance of the MainActivity because the instance on the top of the backstack is of MainActivity. So you can prevent users from opening new instance of same activity which is visible on the screen.</p><p>That’s all for part 1, To learn about SingleTask and SingleInstance checkout the part 2 of this blog.</p><p><a href="https://medium.com/wiselteach/activity-back-stack-and-launch-mode-part-2-e715c724f7cf">Activity Back Stack and Launch Mode Part -2</a></p><p>Please mark ❤ if you like the blog. In case if you find any mistake please mention that in comment. Stay tuned for more tech blogs.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F2acca1%3Fas_embed%3Dtrue&amp;url=https%3A%2F%2Fupscri.be%2F2acca1%2F&amp;image=https%3A%2F%2Fupscri.be%2Fmedia%2Fform.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/34afc03fc364a74f43446ac79eafff71/href">https://medium.com/media/34afc03fc364a74f43446ac79eafff71/href</a></iframe><p><a href="http://www.wiselteach.com/">www.wiselteach.com</a></p><p>#AndroidMonk</p><p>#WiseL #WiseLTeach</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=693130682120" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wiselteach/activity-back-stack-and-launch-mode-part-1-693130682120">Activity Back Stack and Launch Mode Part -1</a> was originally published in <a href="https://medium.com/wiselteach">WiseLTeach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RecyclerView in Android @AndroidMonk]]></title>
            <link>https://medium.com/wiselteach/recyclerview-in-android-androidmonk-e45b96dec0b7?source=rss----6e3d73bea4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/e45b96dec0b7</guid>
            <category><![CDATA[recyclerview]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Rajat Talesra]]></dc:creator>
            <pubDate>Sun, 19 Feb 2017 14:28:10 GMT</pubDate>
            <atom:updated>2017-02-19T14:40:11.305Z</atom:updated>
            <content:encoded><![CDATA[<p>RecyclerView is one of the most important topic in android as it is widely used in almost every application to display data from internet. This blog is mainly for beginners in android.</p><p>Complete Code Link: <a href="https://github.com/rt4914/RecyclerView-Basics/tree/master/RecyclerViewDemo">https://github.com/rt4914/RecyclerView-Basics/tree/master/RecyclerViewDemo</a></p><blockquote><strong><em>Create New Empty Project</em></strong></blockquote><p>Name this project as ‘RecyclerViewDemo’</p><blockquote><strong><em>Gradle File</em></strong></blockquote><p>Add recyclerview dependency inside build.gradle(Module:app)</p><pre><em>//</em><strong><em>TODO(1): Add RecyclerView Library in your gradle File<br></em></strong>compile <strong>&#39;com.android.support:recyclerview-v7:25.1.1&#39;</strong></pre><blockquote><strong><em>Code for activity_main.xml</em></strong></blockquote><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>FrameLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:id=&quot;@+id/activity_main&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    </strong>&gt;<br><br>    <em>&lt;!--</em><strong><em>TODO(2): RecyclerView inside FrameLayout</em></strong><em>--&gt;<br><br>    </em>&lt;<strong>android.support.v7.widget.RecyclerView<br>        android:id=&quot;@+id/rvStudents&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;<br>        android:scrollbars=&quot;none&quot;<br>        </strong>&gt;<br>    &lt;/<strong>android.support.v7.widget.RecyclerView</strong>&gt;<br><br>    <em>&lt;!--</em><strong><em>TODO(3): Create one layout resource with item_student.xml name</em></strong><em>--&gt;<br><br></em>&lt;/<strong>FrameLayout</strong>&gt;</pre><blockquote><strong><em>Create new xml file: item_student.xml</em></strong></blockquote><p>This file will act as UI for each individual item in our recyclerview.</p><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:orientation=&quot;vertical&quot; android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:background=&quot;#d2d2d2&quot;<br>    android:id=&quot;@+id/llItemStudents&quot;<br>    android:layout_margin=&quot;8dp&quot;<br>    </strong>&gt;<br><br>    <em>&lt;!--</em><strong><em>TODO(4): Remember to change the height of LinearLayout to wrap_content and also add its ID</em></strong><em>--&gt;<br><br>    &lt;!--</em><strong><em>TODO(5): Add two TextView which will display student name and mobile number respectively</em></strong><em>--&gt;<br><br>    </em>&lt;<strong>TextView<br>        android:id=&quot;@+id/tvStudentName&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:layout_margin=&quot;8dp&quot;<br>        android:padding=&quot;8dp&quot;<br>        android:textSize=&quot;25sp&quot;<br>        android:textStyle=&quot;bold&quot;<br>        android:textColor=&quot;@color/colorPrimary&quot;<br>        </strong>/&gt;<br><br>    &lt;<strong>TextView<br>        android:id=&quot;@+id/tvMobileNumber&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:layout_margin=&quot;8dp&quot;<br>        android:padding=&quot;8dp&quot;<br>        android:textSize=&quot;22sp&quot;<br>        android:textStyle=&quot;bold&quot;<br>        android:textColor=&quot;@color/colorAccent&quot;<br>        </strong>/&gt;<br><br>&lt;/<strong>LinearLayout</strong>&gt;</pre><blockquote><strong><em>Code for MainActivity.java</em></strong></blockquote><pre><strong>import </strong>android.support.v7.app.AppCompatActivity;<br><strong>import </strong>android.os.Bundle;<br><strong>import </strong>android.support.v7.widget.GridLayoutManager;<br><strong>import </strong>android.support.v7.widget.LinearLayoutManager;<br><strong>import </strong>android.support.v7.widget.RecyclerView;<br><strong>import </strong>android.support.v7.widget.StaggeredGridLayoutManager;<br><strong>import </strong>android.text.Layout;<br><br><strong>import </strong>java.util.ArrayList;<br><br><em>/*<br> * Demo Code of Recycler View<br> * Created on: 19th Feb, 2017<br> * Author Name: Rajat Talesra<br> * Company Name: WiseL<br> * This code is for Android Monk Campus Program.<br> */<br><br>/*<br> * Recycler View is mainly used to show dynamic list of data.<br> * Many applications including Whatsapp, Facebook, Gmail, etc. used RecyclerView<br> *<br> * RecyclerView mainly uses two main components LayoutManager and Adapter<br> *<br> * LayoutManger: Helps to arrange data in LinearLayout or GridLayout<br> *<br> * Adapter: Helps to connect our recycler view with the custom layout and display data on screen<br> *<br> * In this demo we will display students list with their names and mobile numbers.<br> */<br><br></em><strong>public class </strong>MainActivity <strong>extends </strong>AppCompatActivity {<br><br>    <em>//</em><strong><em>TODO(6): Create arrayList for student names and ids.<br><br>    </em></strong>ArrayList&lt;String&gt; <strong>namesArrayList </strong>= <strong>new </strong>ArrayList&lt;&gt;();<br>    ArrayList&lt;String&gt; <strong>mobileArrayList </strong>= <strong>new </strong>ArrayList&lt;&gt;();<br><br>    <em>//</em><strong><em>TODO(7): Declare below mentioned components.<br><br>    </em></strong>RecyclerView <strong>rvStudentsList</strong>;<br>    RecyclerView.LayoutManager <strong>rvLayoutManager</strong>;<br><br>    @Override<br>    <strong>protected void </strong>onCreate(Bundle savedInstanceState) {<br>        <strong>super</strong>.onCreate(savedInstanceState);<br>        setContentView(R.layout.<strong><em>activity_main</em></strong>);<br><br>        <em>//</em><strong><em>TODO(10): Add data to arrayList<br>        </em>namesArrayList</strong>.add(<strong>&quot;Student 1&quot;</strong>);<br>        <strong>namesArrayList</strong>.add(<strong>&quot;Student 2&quot;</strong>);<br>        <strong>namesArrayList</strong>.add(<strong>&quot;Student 3&quot;</strong>);<br>        <strong>namesArrayList</strong>.add(<strong>&quot;Student 4&quot;</strong>);<br>        <strong>namesArrayList</strong>.add(<strong>&quot;Student 5&quot;</strong>);<br>        <strong>namesArrayList</strong>.add(<strong>&quot;Student 6&quot;</strong>);<br>        <strong>namesArrayList</strong>.add(<strong>&quot;Student 7&quot;</strong>);<br>        <strong>namesArrayList</strong>.add(<strong>&quot;Student 8&quot;</strong>);<br>        <strong>namesArrayList</strong>.add(<strong>&quot;Student 9&quot;</strong>);<br>        <strong>namesArrayList</strong>.add(<strong>&quot;Student 10&quot;</strong>);<br><br>        <strong>mobileArrayList</strong>.add(<strong>&quot;8766986401&quot;</strong>);<br>        <strong>mobileArrayList</strong>.add(<strong>&quot;8766986402&quot;</strong>);<br>        <strong>mobileArrayList</strong>.add(<strong>&quot;8766986403&quot;</strong>);<br>        <strong>mobileArrayList</strong>.add(<strong>&quot;8766986404&quot;</strong>);<br>        <strong>mobileArrayList</strong>.add(<strong>&quot;8766986405&quot;</strong>);<br>        <strong>mobileArrayList</strong>.add(<strong>&quot;8766986406&quot;</strong>);<br>        <strong>mobileArrayList</strong>.add(<strong>&quot;8766986407&quot;</strong>);<br>        <strong>mobileArrayList</strong>.add(<strong>&quot;8766986408&quot;</strong>);<br>        <strong>mobileArrayList</strong>.add(<strong>&quot;8766986409&quot;</strong>);<br>        <strong>mobileArrayList</strong>.add(<strong>&quot;8766986410&quot;</strong>);<br><br>        <em>//</em><strong><em>TODO(9): Connect UI elements with java objects.<br>        </em>rvStudentsList </strong>= (RecyclerView) findViewById(R.id.<strong><em>rvStudents</em></strong>);<br><br><br>        <em>//User this to display items vertically<br>        </em><strong>rvLayoutManager </strong>= <strong>new </strong>LinearLayoutManager(<strong>this</strong>);<br><br>        <em>//User this to display items in Grid Layout with 2 columns<br>        //rvLayoutManager = new GridLayoutManager(this,2);<br><br>        //</em><strong><em>TODO(10): Attach layoutManager to recycler view<br>        </em>rvStudentsList</strong>.setLayoutManager(<strong>rvLayoutManager</strong>);<br><br>        <em>/*<br>         * Now we need to create one adapter, so that we can display data row wise<br>         * For this we will create our custom adapter, i.e. StudentAdapter.java<br>         */<br><br>        //</em><strong><em>TODO(11): Create new java class StudentAdapter.java<br><br>        </em></strong><em>//</em><strong><em>TODO(16): Pass data to our custom adapter<br>        </em></strong>StudentAdapter studentAdapter = <strong>new </strong>StudentAdapter(<strong>this</strong>,<strong>namesArrayList</strong>,<strong>mobileArrayList</strong>);<br><br>        <em>//</em><strong><em>TODO(17): Attach studentAdapter to recycler view<br><br>        </em>rvStudentsList</strong>.setAdapter(studentAdapter);<br><br>        <em>//</em><strong><em>TODO(18): Run your app.<br><br>    </em></strong>}<br>}</pre><blockquote><strong><em>Create StudentAdapter.java</em></strong></blockquote><p>Now create new java class with above name which will act as custom adapter for our recyclerview</p><pre><strong>import </strong>android.content.Context;<br><strong>import </strong>android.support.v7.widget.RecyclerView;<br><strong>import </strong>android.view.LayoutInflater;<br><strong>import </strong>android.view.View;<br><strong>import </strong>android.view.ViewGroup;<br><strong>import </strong>android.widget.LinearLayout;<br><strong>import </strong>android.widget.TextView;<br><strong>import </strong>android.widget.Toast;<br><br><strong>import </strong>java.util.ArrayList;<br><br><em>//</em><strong><em>TODO(12): StudentAdapter extends RecyclerView Adapter with ViewHolder class<br><br><br></em>public class </strong>StudentAdapter <strong>extends </strong>RecyclerView.Adapter&lt;StudentAdapter.ViewHolder&gt; {<br><br>    <em>//</em><strong><em>TODO(13): Create two empty arrayList and one context variable;<br><br>    </em></strong>Context <strong>mainActivityContext</strong>;<br>    ArrayList&lt;String&gt; <strong>namesArrayList </strong>= <strong>new </strong>ArrayList&lt;&gt;();<br>    ArrayList&lt;String&gt; <strong>mobileArrayList </strong>= <strong>new </strong>ArrayList&lt;&gt;();<br><br>    <em>//</em><strong><em>TODO(14): Create one constructor with three parameters which will passed from MainActivity class<br><br>    </em>public </strong>StudentAdapter(Context mainActivityContext, ArrayList&lt;String&gt; namesArrayList, ArrayList&lt;String&gt; mobileArrayList) {<br>        <strong>this</strong>.<strong>mainActivityContext </strong>= mainActivityContext;<br>        <strong>this</strong>.<strong>namesArrayList </strong>= namesArrayList;<br>        <strong>this</strong>.<strong>mobileArrayList </strong>= mobileArrayList;<br>    }<br><br>    <em>//</em><strong><em>TODO(15): Complete each method as mentioned below<br><br><br>    </em></strong>@Override<br>    <strong>public </strong>StudentAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, <strong>int </strong>viewType) {<br>        <em>//Used to connect our custom UI to our recycler view<br><br>        </em>View v = LayoutInflater<br>                .<em>from</em>(parent.getContext())<br>                .inflate(R.layout.<strong><em>item_student</em></strong>, parent, <strong>false</strong>);<br><br>        <strong>return new </strong>ViewHolder(v);<br>    }<br><br>    @Override<br>    <strong>public void </strong>onBindViewHolder(StudentAdapter.ViewHolder holder, <strong>int </strong>position) {<br>        <em>//Used to set data in each row of recycler view<br><br>        </em>String currentName = <strong>namesArrayList</strong>.get(position);<br>        String currentMobileNumber = <strong>mobileArrayList</strong>.get(position);<br><br>        holder.<strong>tvName</strong>.setText(currentName);<br>        holder.<strong>tvMobileNumber</strong>.setText(currentMobileNumber);<br><br>    }<br><br>    @Override<br>    <strong>public int </strong>getItemCount() {<br>        <em>//Returns total number of rows inside recycler view<br><br>        </em><strong>return namesArrayList</strong>.size();<br>    }<br><br>    <strong>public class </strong>ViewHolder <strong>extends </strong>RecyclerView.ViewHolder {<br>        <em>//Used to work with the elements of our custom UI.<br><br>        </em>LinearLayout <strong>llItemStudents</strong>;<br><br>        TextView <strong>tvName</strong>;<br>        TextView <strong>tvMobileNumber</strong>;<br><br>        <strong>public </strong>ViewHolder(View itemView) {<br>            <strong>super</strong>(itemView);<br><br>            <strong>tvName </strong>= (TextView) itemView.findViewById(R.id.<strong><em>tvStudentName</em></strong>);<br>            <strong>tvMobileNumber </strong>= (TextView) itemView.findViewById(R.id.<strong><em>tvMobileNumber</em></strong>);<br><br>            <strong>llItemStudents </strong>= (LinearLayout) itemView.findViewById(R.id.<strong><em>llItemStudents</em></strong>);<br><br>            <strong>llItemStudents</strong>.setOnClickListener(<strong>new </strong>View.OnClickListener() {<br>                @Override<br>                <strong>public void </strong>onClick(View v) {<br>                    Toast.<em>makeText</em>(<strong>mainActivityContext</strong>,<br>                            <strong>&quot;You clicked item number: &quot;</strong>+ getAdapterPosition(),<br>                            Toast.<strong><em>LENGTH_SHORT</em></strong>).show();<br>                }<br>            });<br><br>        }<br>    }<br>}</pre><blockquote><strong><em>Flow diagram of code</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*NV6rAwwA5qdoNVaZNIMiHQ.jpeg" /><figcaption>Flow Diagram Recycler View</figcaption></figure><p>You can the run the app to display your data inside recyclerview</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Awu0dhevQ0YF56_D9RzrwQ.png" /><figcaption>RecyclerView with Student Names and Mobile Numbers</figcaption></figure><p>Feel free to comment.</p><p>#AndroidMonk</p><p>#WiseL</p><p>#WiseLTeach</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e45b96dec0b7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wiselteach/recyclerview-in-android-androidmonk-e45b96dec0b7">RecyclerView in Android @AndroidMonk</a> was originally published in <a href="https://medium.com/wiselteach">WiseLTeach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No more “Present Sir” @100Cent]]></title>
            <link>https://medium.com/wiselteach/no-more-present-sir-100cent-e4613c301ebc?source=rss----6e3d73bea4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/e4613c301ebc</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[WiseL Teach]]></dc:creator>
            <pubDate>Sun, 19 Feb 2017 09:22:41 GMT</pubDate>
            <atom:updated>2017-02-13T08:20:14.308Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*565yuwBvuCcwQr6jIwruOQ.png" /></figure><p>This post is regarding the most obvious problem which many schools, institutes, universities face — <strong>Attendance</strong>. But what if we tell you that we have got a unique way to deal with the whole attendance system which is hassle-free, effortless as well as no additional resources are required. Well, we will come to that later….</p><p>The thing about attendance is that students and teachers have a completely different perspective of the same. Students find attendance to be a nuisance at some point in their higher standards due to several reasons and the teachers find it a necessity to maintain a certain standard of education.</p><p>Some teachers are quite liberal about the whole attendance thing, whereas some are strict but one problem that all face is about the way attendance is conducted. Teacher reciting some of the most ‘difficult to spell’ names and students raising their hands and shouting at the top of their voices. And by chance, if the teacher spelled the name incorrectly the name sticks with the students forever. While some of the esteemed institutions have used biometric sensors, but nowadays students have identified ways to beat that too. Others have used more high-end technology but that includes system installations and more money.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*v349FPRMXFZIunqH0wpwKQ.png" /></figure><p>Here<strong>,</strong> we bring to you a technologically oriented way to take attendance, which won’t take significant time and also the students will have fun doing that. Our team is working hard to create an easy and smart way of taking attendance in this digital era. We will be launching our product soon and will be giving free trial to selected institutions.</p><p>We are launching the preview of our product on 14th Feb 2017, 7:00 PM IST on our <a href="http://www.fb.com/WiseLearningSolutions">facebook page</a>.</p><p>Stay tuned for more updates!</p><p>#100Cent #ComingSoon</p><p>#WiseLTech #WiseLTeach #WiseL</p><p>For further details follow us at:</p><p>Facebook Page: <a href="https://www.facebook.com/WiseLearningSolutions/?ref=aymt_homepage_panel">www.fb.com/WiseLearningSolutions</a></p><p>Google +: <a href="https://plus.google.com/114834973121730067007">https://plus.google.com/114834973121730067007</a></p><p>Medium: <a href="https://medium.com/@teachwisel">https://medium.com/@teachwisel</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4613c301ebc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wiselteach/no-more-present-sir-100cent-e4613c301ebc">No more “Present Sir” @100Cent</a> was originally published in <a href="https://medium.com/wiselteach">WiseLTeach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android SQLite database @AndroidMonk]]></title>
            <link>https://medium.com/wiselteach/android-sqlite-database-androidmonk-6b92d1bdf33b?source=rss----6e3d73bea4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/6b92d1bdf33b</guid>
            <category><![CDATA[sqlite]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[WiseL Teach]]></dc:creator>
            <pubDate>Sun, 19 Feb 2017 09:22:22 GMT</pubDate>
            <atom:updated>2017-02-09T07:29:50.676Z</atom:updated>
            <content:encoded><![CDATA[<p>Android provides multiple ways to store data in app locally, one of these ways is SQLite database.</p><p>SQLite is a very light weight database which comes with Android OS.</p><p>Lets dive into the code.</p><p>For this tutorial we will be creating a table of students with there <em>studentID</em>, <em>studentName </em>and <em>studentEmail</em>. In this case <em>studentID </em>will act as primary key. Table name will be <em>students </em>and database name will be <em>studentDetails</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*eFEmiWlZB-5sGDS5pZ2wgw.png" /></figure><p>We will create similar table in SQLite. We will perform CRUD operations of this table .</p><p>C-Create/Insert R-Read U-Update D-Delete</p><p>We will need MainActivity.java to add our data to database and also to retrieve our data for this tutorial purpose.</p><p>We will need DBHandler.java to control our SQLite database.</p><p>We will need of StudentModel.java to access each individual row easily.</p><p>The codes are well commented for your ease.</p><blockquote><strong><em>StudentModel.java</em></strong></blockquote><pre><em>/**<br> * Created by rajat@wiselteach.com <br> */<br><br></em><strong>public class </strong>StudentModel {<br><br>    <em>//We will use this file for easy access to each row in the table.<br>    <br>    </em><strong>int studentID</strong>;<br>    String <strong>studentName</strong>;<br>    String <strong>studentEmail</strong>;<br><br>    <em>//Constructor to set data in StudentModel directly.<br>    </em><strong>public </strong>StudentModel(<strong>int </strong>studentID, String studentName, String studentEmail) {<br>        <strong>this</strong>.<strong>studentID </strong>= studentID;<br>        <strong>this</strong>.<strong>studentName </strong>= studentName;<br>        <strong>this</strong>.<strong>studentEmail </strong>= studentEmail;<br>    }<br><br>    <strong>public int </strong>getStudentID() {<br>        <strong>return studentID</strong>;<br>    }<br><br>    <strong>public void </strong>setStudentID(<strong>int </strong>studentID) {<br>        <strong>this</strong>.<strong>studentID </strong>= studentID;<br>    }<br><br>    <strong>public </strong>String getStudentName() {<br>        <strong>return studentName</strong>;<br>    }<br><br>    <strong>public void </strong>setStudentName(String studentName) {<br>        <strong>this</strong>.<strong>studentName </strong>= studentName;<br>    }<br><br>    <strong>public </strong>String getStudentEmail() {<br>        <strong>return studentEmail</strong>;<br>    }<br><br>    <strong>public void </strong>setStudentEmail(String studentEmail) {<br>        <strong>this</strong>.<strong>studentEmail </strong>= studentEmail;<br>    }<br>}</pre><blockquote><strong><em>DBHandler.java</em></strong></blockquote><pre><strong>import </strong>android.content.ContentValues;<br><strong>import </strong>android.content.Context;<br><strong>import </strong>android.database.Cursor;<br><strong>import </strong>android.database.sqlite.SQLiteDatabase;<br><strong>import </strong>android.database.sqlite.SQLiteOpenHelper;<br><br><strong>import </strong>java.util.ArrayList;<br><strong>import </strong>java.util.List;<br><br><br><strong>public class </strong>DBHandler <strong>extends </strong>SQLiteOpenHelper {<br><br>    <em>//Database version.<br>    //Note: Increase the database version every-time you make changes to your table structure.<br>    </em><strong>private static final int <em>DATABASE_VERSION </em></strong>= 1;<br><br>    <em>//Database Name<br>    </em><strong>private static final </strong>String <strong><em>DATABASE_NAME </em></strong>= <strong>&quot;studentDetails&quot;</strong>;<br><br>    <em>//You will declare all your table names here.<br>    </em><strong>private static final </strong>String <strong><em>TABLE_STUDENTS </em></strong>= <strong>&quot;students&quot;</strong>;<br><br>    <em>// Students Table Columns names<br>    </em><strong>private static final </strong>String <strong><em>KEY_STUDENT_ID </em></strong>= <strong>&quot;studentID&quot;</strong>;<br>    <strong>private static final </strong>String <strong><em>KEY_STUDENT_NAME </em></strong>= <strong>&quot;studentName&quot;</strong>;<br>    <strong>private static final </strong>String <strong><em>KEY_STUDENT_EMAIL </em></strong>= <strong>&quot;studentEmail&quot;</strong>;<br><br>    <em>//Here context passed will be of application and not activity.<br>    </em><strong>public </strong>DBHandler(Context context) {<br>        <strong>super</strong>(context, <strong><em>DATABASE_NAME</em></strong>, <strong>null</strong>, <strong><em>DATABASE_VERSION</em></strong>);<br>    }<br><br>    <em>//This method will be called every-time the file is called.<br>    </em>@Override<br>    <strong>public void </strong>onCreate(SQLiteDatabase db) {<br>        <em>//Query to create table<br>        </em>String CREATE_STUDENTS_TABLE = <strong>&quot;CREATE TABLE IF NOT EXISTS &quot;<br>                </strong>+ <strong><em>TABLE_STUDENTS </em></strong>+ <strong>&quot;(&quot;<br>                </strong>+ <strong><em>KEY_STUDENT_ID </em></strong>+ <strong>&quot; INTEGER (10) PRIMARY KEY, &quot;<br>                </strong>+ <strong><em>KEY_STUDENT_NAME </em></strong>+ <strong>&quot; TEXT, &quot;<br>                </strong>+ <strong><em>KEY_STUDENT_EMAIL </em></strong>+ <strong>&quot; TEXT&quot; </strong>+ <strong>&quot;)&quot;</strong>;<br><br>        <em>//Create table query executed in sqlite<br>        </em>db.execSQL(CREATE_STUDENTS_TABLE);<br>    }<br><br>    @Override<br>    <strong>public void </strong>onUpgrade(SQLiteDatabase db, <strong>int </strong>oldVersion, <strong>int </strong>newVersion) {<br>        <em>//This method will be called only if there is change in DATABASE_VERSION.<br><br>        // Drop older table if existed<br>        </em>db.execSQL(<strong>&quot;DROP TABLE IF EXISTS &quot; </strong>+ <strong><em>TABLE_STUDENTS</em></strong>);<br><br>        <em>// Create tables again<br>        </em>onCreate(db);<br>    }<br><br>    <em>/**<br>     * All CRUD(Create, Read, Update, Delete) Operations<br>     */<br><br>    // Add New Student<br>    </em><strong>public void </strong>addStudent(StudentModel student) {<br>        SQLiteDatabase db = <strong>this</strong>.getWritableDatabase();<br><br>        <em>//Content values use KEY-VALUE pair concept<br>        </em>ContentValues values = <strong>new </strong>ContentValues();<br>        values.put(<strong><em>KEY_STUDENT_ID</em></strong>, student.getStudentID());<br>        values.put(<strong><em>KEY_STUDENT_NAME</em></strong>, student.getStudentName());<br>        values.put(<strong><em>KEY_STUDENT_EMAIL</em></strong>, student.getStudentEmail());<br><br>        db.insert(<strong><em>TABLE_STUDENTS</em></strong>, <strong>null</strong>, values);<br>        db.close();<br>    }<br><br>    <em>// Getting single student details through ID<br>    </em><strong>public </strong>StudentModel getStudent(<strong>int </strong>studentID) {<br><br>        SQLiteDatabase db = <strong>this</strong>.getReadableDatabase();<br><br><br>        <em>//You can browse to the query method to know more about the arguments.<br>        </em>Cursor cursor = db.query(<strong><em>TABLE_STUDENTS</em></strong>,<br>                <strong>new </strong>String[] { <strong><em>KEY_STUDENT_ID</em></strong>, <strong><em>KEY_STUDENT_NAME</em></strong>, <strong><em>KEY_STUDENT_EMAIL </em></strong>},<br>                <strong><em>KEY_STUDENT_ID </em></strong>+ <strong>&quot;=?&quot;</strong>,<br>                <strong>new </strong>String[] { String.<em>valueOf</em>(studentID) },<br>                <strong>null</strong>,<br>                <strong>null</strong>,<br>                <strong>null</strong>,<br>                <strong>null</strong>);<br><br>        <strong>if </strong>(cursor != <strong>null</strong>)<br>            cursor.moveToFirst();<br><br>        StudentModel student = <strong>new </strong>StudentModel(<br>                Integer.<em>parseInt</em>(cursor.getString(0)),<br>                cursor.getString(1),<br>                cursor.getString(2));<br><br>        <em>//Return Student<br>        </em><strong>return </strong>student;<br>    }<br><br>    <em>// Getting All Students<br>    </em><strong>public </strong>List&lt;StudentModel&gt; getAllStudents() {<br>        List&lt;StudentModel&gt; studentList = <strong>new </strong>ArrayList&lt;StudentModel&gt;();<br><br>        <em>// Select All Query<br>        </em>String selectQuery = <strong>&quot;SELECT  * FROM &quot; </strong>+ <strong><em>TABLE_STUDENTS</em></strong>;<br><br>        SQLiteDatabase db = <strong>this</strong>.getWritableDatabase();<br>        Cursor cursor = db.rawQuery(selectQuery, <strong>null</strong>);<br><br>        <em>// Looping through all rows and adding to list<br>        </em><strong>if </strong>(cursor.moveToFirst()) {<br>            <strong>do </strong>{<br>                StudentModel student = <strong>new </strong>StudentModel(<br>                        cursor.getInt(0),<br>                        cursor.getString(1),<br>                        cursor.getString(2));<br><br>                studentList.add(student);<br>            } <strong>while </strong>(cursor.moveToNext());<br>        }<br><br>        <em>// return student list<br>        </em><strong>return </strong>studentList;<br>    }<br><br>    <em>// Updating single student<br>    </em><strong>public int </strong>updateStudent(StudentModel student) {<br>        SQLiteDatabase db = <strong>this</strong>.getWritableDatabase();<br><br>        ContentValues values = <strong>new </strong>ContentValues();<br>        values.put(<strong><em>KEY_STUDENT_NAME</em></strong>, student.getStudentName());<br>        values.put(<strong><em>KEY_STUDENT_EMAIL</em></strong>, student.getStudentEmail());<br><br>        <em>// updating student row<br>        </em><strong>return </strong>db.update(<strong><em>TABLE_STUDENTS</em></strong>,<br>                values,<br>                <strong><em>KEY_STUDENT_ID </em></strong>+ <strong>&quot; = ?&quot;</strong>,<br>                <strong>new </strong>String[] { String.<em>valueOf</em>(student.getStudentID())});<br><br>    }<br><br>    <em>// Deleting single student<br>    </em><strong>public void </strong>deleteStudent(StudentModel student) {<br><br>        SQLiteDatabase db = <strong>this</strong>.getWritableDatabase();<br>        db.delete(<strong><em>TABLE_STUDENTS</em></strong>, <strong><em>KEY_STUDENT_ID </em></strong>+ <strong>&quot; = ?&quot;</strong>,<br>                <strong>new </strong>String[] { String.<em>valueOf</em>(student.getStudentID()) });<br>        db.close();<br>    }<br><br><br>    <em>// Getting students count<br>    </em><strong>public int </strong>getStudentsCount() {<br>        String countQuery = <strong>&quot;SELECT  * FROM &quot; </strong>+ <strong><em>TABLE_STUDENTS</em></strong>;<br>        SQLiteDatabase db = <strong>this</strong>.getReadableDatabase();<br>        Cursor cursor = db.rawQuery(countQuery, <strong>null</strong>);<br>        cursor.close();<br><br>        <em>// return count<br>        </em><strong>return </strong>cursor.getCount();<br>    }<br><br>}</pre><blockquote><strong><em>MainActivity.java</em></strong></blockquote><pre><strong>import </strong>android.os.Bundle;<br><strong>import </strong>android.support.v7.app.AppCompatActivity;<br><strong>import </strong>android.util.Log;<br><br><strong>import </strong>java.util.List;<br><br><strong>public class </strong>MainActivity <strong>extends </strong>AppCompatActivity {<br><br>    DBHandler <strong>db</strong>;<br>    @Override<br>    <strong>protected void </strong>onCreate(Bundle savedInstanceState) {<br>        <strong>super</strong>.onCreate(savedInstanceState);<br>        setContentView(R.layout.<strong><em>activity_main</em></strong>);<br><br>        <em>//Creating object to use DBHandler<br>        </em><strong>db </strong>= <strong>new </strong>DBHandler(<strong>this</strong>);<br><br>        addDataToDatabase();<br><br>        readDataFromDatabase();<br>    }<br><br>    <strong>private void </strong>readDataFromDatabase() {<br><br>        <em>// Reading all students<br>        </em>Log.<em>d</em>(<strong>&quot;MainActivity&quot;</strong>, <strong>&quot;Reading all students..&quot;</strong>);<br>        List&lt;StudentModel&gt; students = <strong>db</strong>.getAllStudents();<br><br>        <strong>for </strong>(StudentModel i : students) {<br>            String log = <strong>&quot;Id: &quot; </strong>+ i.getStudentID() + <strong>&quot; ,Name: &quot; </strong>+ i.getStudentName() + <strong>&quot; ,Email: &quot; </strong>+ i.getStudentEmail();<br>            <em>// Writing students to log<br>            </em>Log.<em>d</em>(<strong>&quot;MainActivity&quot;</strong>, log);<br>        }<br><br>    }<br><br>    <strong>private void </strong>addDataToDatabase() {<br>        <em>// Inserting Students<br>        </em>Log.<em>d</em>(<strong>&quot;MainActivity&quot;</strong>, <strong>&quot;Inserting ..&quot;</strong>);<br>        <strong>db</strong>.addStudent(<strong>new </strong>StudentModel(234567, <strong>&quot;Rajat&quot;</strong>, <strong>&quot;rajat@gmail.com&quot;</strong>));<br>        <strong>db</strong>.addStudent(<strong>new </strong>StudentModel(955689, <strong>&quot;ABC&quot;</strong>, <strong>&quot;abc@gmail.com&quot;</strong>));<br>        <strong>db</strong>.addStudent(<strong>new </strong>StudentModel(345129, <strong>&quot;XYZ&quot;</strong>, <strong>&quot;xyz@gmail.com&quot;</strong>));<br>    }<br>}</pre><blockquote><strong><em>Result in Logcat</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*yvOP_BEiGlqFNkocZy0hnw.png" /></figure><p>Feel free to comment down below.</p><p>#AndroidMonk</p><p>#WiseLTeach</p><p>#<a href="http://wiselteach.com/">WiseL</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b92d1bdf33b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wiselteach/android-sqlite-database-androidmonk-6b92d1bdf33b">Android SQLite database @AndroidMonk</a> was originally published in <a href="https://medium.com/wiselteach">WiseLTeach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mission2000: AndroidMonk 1st Workshop Review]]></title>
            <link>https://medium.com/wiselteach/mission-2000-androidmonk-1st-workshop-review-137d5a5eb2cd?source=rss----6e3d73bea4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/137d5a5eb2cd</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[WiseL Teach]]></dc:creator>
            <pubDate>Sun, 19 Feb 2017 09:21:58 GMT</pubDate>
            <atom:updated>2017-01-20T15:53:49.486Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TFnqwJSxs5D9YOvcFJ5S5w.png" /></figure><p><strong>Mission2000</strong>: AndroidMonk 1st Workshop Review</p><p>AndroidMonk, an initiative by WiseL, focuses on strengthening the android skills of college students through various course tracks and workshops. For the year <strong>2017</strong> we are targeting to reach at-least <strong>2000 students</strong> to deliver android knowledge.</p><p>We started this year with our first version of AndroidMonk Workshop for IIIT- Vadodara students. We saw 41 participants for the 1st workshop and we are already booked for next 4 weeks regarding various classes and workshops.</p><p>The reviews of the 1st workshop participants are mentioned below:</p><blockquote>Special Email by <a href="https://medium.com/u/eb1c17dd31ca">Saurabh:</a></blockquote><blockquote>“<strong>Tell me, and I will forget. Show me, and I may remember.</strong></blockquote><blockquote><strong>Involve me, and I will understand.</strong>“ Confucius 450 BC</blockquote><blockquote>An Android development workshop “Android Monk” was organized for IIIT-V students in collaboration with WiseL on 7th to 8th January 2017. The speaker of this workshop was Mr. Rajat Talesra who made sure that workshop remains informative as well entertaining.</blockquote><blockquote>The 16+ hour workshop aimed to increase the capacity of students to develop and implement Android apps. It also presented a holistic view of Android development and helped to enhance collaborative learning around the latest technology and breakthrough in Android industry.</blockquote><blockquote>The key highlights were JSON parsing &amp; XML, Tabs, Fragments, Material design and Firebase concepts which I think were essential part of learning for budding Android developer.</blockquote><blockquote>Overall It was a great fun and a good learning experience for me. And I hope these kinds of technical workshops will elevate the developing community in our IIIT- Vadodara.</blockquote><blockquote>Feeling motivated for learning more and more, the session was worth attending. — Mehak Piplani</blockquote><blockquote>Good coding practices, constraint layout &amp;&amp; motivation to excel in development. — Yash Ladha</blockquote><blockquote>I am able to make apps as directed and at least now I know where I have to work in Android. It was good. I personally think the speaker is good and informed. — Harshit Jain</blockquote><p>Overall, we got great response with 100% interest in next events that we conduct. Thank you to all the participants and volunteers for their great enthusiasm. We will be soon coming up with the products that these students have created in their workshops.</p><p>Stay tuned. Follow us for more updates.</p><p><a href="http://wiselteach.com/">http://www.wiselteach.com/</a></p><p><a href="https://www.facebook.com/WiseLearningSolutions/?ref=aymt_homepage_panel">https://www.facebook.com/WiseLearningSolutions</a></p><p>#Mission2000</p><p>#AndroidMonk</p><p>#WiselTeach #Wisel</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=137d5a5eb2cd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wiselteach/mission-2000-androidmonk-1st-workshop-review-137d5a5eb2cd">Mission2000: AndroidMonk 1st Workshop Review</a> was originally published in <a href="https://medium.com/wiselteach">WiseLTeach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tic-Tac-Toe (TableLayout) Android App @AndroidMonk]]></title>
            <link>https://medium.com/wiselteach/tic-tac-toe-tablelayout-android-app-androidmonk-a56b9e1c6a15?source=rss----6e3d73bea4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/a56b9e1c6a15</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[WiseL Teach]]></dc:creator>
            <pubDate>Sun, 19 Feb 2017 09:21:28 GMT</pubDate>
            <atom:updated>2017-01-27T11:33:30.010Z</atom:updated>
            <content:encoded><![CDATA[<p>Tic-Tac-Toe is a very simple 3x3 game and probably everyone have played this game at-least once. In this tutorial, we will create a simple 3x3 tic-tac-toe app. This motive of this tutorial is you know more about table layout in android.</p><p>NOTE: You can find a lot of Tic-Tac-Toe codes on internet but this one is probably the best for beginners with everything kept simple and covering each and every case neatly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*AhuZg1Dnsz9yjQYIzKvFoQ.png" /></figure><blockquote><strong><em>Creating the UI</em></strong></blockquote><p>Table Layout for arrangement of buttons in 3x3 view</p><p>Text View for showing game information</p><p>Button to reset the board anytime</p><p>Add below code in your activity_main.xml file.</p><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:id=&quot;@+id/activity_main&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    android:paddingBottom=&quot;@dimen/activity_vertical_margin&quot;<br>    android:paddingLeft=&quot;@dimen/activity_horizontal_margin&quot;<br>    android:paddingRight=&quot;@dimen/activity_horizontal_margin&quot;<br>    android:paddingTop=&quot;@dimen/activity_vertical_margin&quot;<br>    </strong>&gt;<br>    <br>    <em>&lt;!--Table Layout with 3 rows and each row with 3 buttons--&gt;<br>    </em>&lt;<strong>TableLayout<br>        android:id=&quot;@+id/glGameBoard&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:layout_centerHorizontal=&quot;true&quot;<br>        android:layout_below=&quot;@+id/tvInfo&quot;<br>        android:rowCount=&quot;3&quot;<br>        android:columnCount=&quot;3&quot;<br>        android:padding=&quot;8dp&quot;<br>        </strong>&gt;<br><br>        <em>&lt;!--Row 1--&gt;<br>        </em>&lt;<strong>TableRow</strong>&gt;<br><br>            &lt;<strong>Button<br>                android:id=&quot;@+id/b00&quot;<br>                android:layout_width=&quot;80dp&quot;<br>                android:layout_height=&quot;80dp&quot;<br>                android:textSize=&quot;22sp&quot;<br>                android:textColor=&quot;#FFFFFF&quot;<br>                android:background=&quot;@color/colorAccent&quot;<br>                android:gravity=&quot;center&quot;<br>                android:layout_margin=&quot;8dp&quot;<br>                style=&quot;@style/Widget.AppCompat.Button&quot;<br>                </strong>/&gt;<br>    <br>            &lt;<strong>Button<br>                android:id=&quot;@+id/b01&quot;<br>                android:layout_width=&quot;80dp&quot;<br>                android:layout_height=&quot;80dp&quot;<br>                android:textSize=&quot;22sp&quot;<br>                android:textColor=&quot;#FFFFFF&quot;<br>                android:background=&quot;@color/colorAccent&quot;<br>                android:gravity=&quot;center&quot;<br>                android:layout_margin=&quot;8dp&quot;<br>                style=&quot;@style/Widget.AppCompat.Button&quot;<br>                </strong>/&gt;<br>    <br>            &lt;<strong>Button<br>                android:id=&quot;@+id/b02&quot;<br>                android:layout_width=&quot;80dp&quot;<br>                android:layout_height=&quot;80dp&quot;<br>                android:textSize=&quot;22sp&quot;<br>                android:textColor=&quot;#FFFFFF&quot;<br>                android:background=&quot;@color/colorAccent&quot;<br>                android:gravity=&quot;center&quot;<br>                android:layout_margin=&quot;8dp&quot;<br>                style=&quot;@style/Widget.AppCompat.Button&quot;<br>                </strong>/&gt;<br><br>        &lt;/<strong>TableRow</strong>&gt;<br><br>        <em>&lt;!--Row 2--&gt;<br>        </em>&lt;<strong>TableRow</strong>&gt;<br>            <br>            &lt;<strong>Button<br>                android:id=&quot;@+id/b10&quot;<br>                android:layout_width=&quot;80dp&quot;<br>                android:layout_height=&quot;80dp&quot;<br>                android:textSize=&quot;22sp&quot;<br>                android:textColor=&quot;#FFFFFF&quot;<br>                android:background=&quot;@color/colorAccent&quot;<br>                android:gravity=&quot;center&quot;<br>                android:layout_margin=&quot;8dp&quot;<br>                style=&quot;@style/Widget.AppCompat.Button&quot;<br>                </strong>/&gt;<br>    <br>            &lt;<strong>Button<br>                android:id=&quot;@+id/b11&quot;<br>                android:layout_width=&quot;80dp&quot;<br>                android:layout_height=&quot;80dp&quot;<br>                android:textSize=&quot;22sp&quot;<br>                android:textColor=&quot;#FFFFFF&quot;<br>                android:background=&quot;@color/colorAccent&quot;<br>                android:gravity=&quot;center&quot;<br>                android:layout_margin=&quot;8dp&quot;<br>                style=&quot;@style/Widget.AppCompat.Button&quot;<br>                </strong>/&gt;<br>    <br>            &lt;<strong>Button<br>                android:id=&quot;@+id/b12&quot;<br>                android:layout_width=&quot;80dp&quot;<br>                android:layout_height=&quot;80dp&quot;<br>                android:textSize=&quot;22sp&quot;<br>                android:textColor=&quot;#FFFFFF&quot;<br>                android:background=&quot;@color/colorAccent&quot;<br>                android:gravity=&quot;center&quot;<br>                android:layout_margin=&quot;8dp&quot;<br>                style=&quot;@style/Widget.AppCompat.Button&quot;<br>                </strong>/&gt;<br><br>        &lt;/<strong>TableRow</strong>&gt;<br><br>        <em>&lt;!--Row 3--&gt;<br>        </em>&lt;<strong>TableRow</strong>&gt;<br><br>            &lt;<strong>Button<br>                android:id=&quot;@+id/b20&quot;<br>                android:layout_width=&quot;80dp&quot;<br>                android:layout_height=&quot;80dp&quot;<br>                android:textSize=&quot;22sp&quot;<br>                android:textColor=&quot;#FFFFFF&quot;<br>                android:background=&quot;@color/colorAccent&quot;<br>                android:gravity=&quot;center&quot;<br>                android:layout_margin=&quot;8dp&quot;<br>                style=&quot;@style/Widget.AppCompat.Button&quot;<br>                </strong>/&gt;<br>    <br>            &lt;<strong>Button<br>                android:id=&quot;@+id/b21&quot;<br>                android:layout_width=&quot;80dp&quot;<br>                android:layout_height=&quot;80dp&quot;<br>                android:textSize=&quot;22sp&quot;<br>                android:textColor=&quot;#FFFFFF&quot;<br>                android:background=&quot;@color/colorAccent&quot;<br>                android:gravity=&quot;center&quot;<br>                android:layout_margin=&quot;8dp&quot;<br>                style=&quot;@style/Widget.AppCompat.Button&quot;<br>                </strong>/&gt;<br>    <br>            &lt;<strong>Button<br>                android:id=&quot;@+id/b22&quot;<br>                android:layout_width=&quot;80dp&quot;<br>                android:layout_height=&quot;80dp&quot;<br>                android:textSize=&quot;22sp&quot;<br>                android:textColor=&quot;#FFFFFF&quot;<br>                android:background=&quot;@color/colorAccent&quot;<br>                android:gravity=&quot;center&quot;<br>                android:layout_margin=&quot;8dp&quot;<br>                style=&quot;@style/Widget.AppCompat.Button&quot;<br>                </strong>/&gt;<br><br>        &lt;/<strong>TableRow</strong>&gt;<br><br>    &lt;/<strong>TableLayout</strong>&gt;<br><br>    <em>&lt;!--TextView to show user turns and winner--&gt;<br>    </em>&lt;<strong>TextView<br>        android:id=&quot;@+id/tvInfo&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:textColor=&quot;#424242&quot;<br>        android:textSize=&quot;18sp&quot;<br>        android:layout_centerHorizontal=&quot;true&quot;<br>        android:layout_margin=&quot;16dp&quot;<br>        android:padding=&quot;8dp&quot;<br>        </strong>/&gt;<br><br>    <em>&lt;!--Button to reset game board--&gt;<br>    </em>&lt;<strong>Button<br>        android:id=&quot;@+id/bReset&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:layout_below=&quot;@+id/glGameBoard&quot;<br>        android:layout_centerHorizontal=&quot;true&quot;<br>        android:layout_margin=&quot;16dp&quot;<br>        android:padding=&quot;8dp&quot;<br>        android:text=&quot;RESET&quot;<br>        android:textSize=&quot;18sp&quot;<br>        android:textColor=&quot;#FFFFFF&quot;<br>        android:background=&quot;@color/colorPrimary&quot;<br>        </strong>/&gt;<br><br>&lt;/<strong>RelativeLayout</strong>&gt;</pre><blockquote><strong><em>Complete Code</em></strong></blockquote><p>Please read the comments in the code first to understand the role of each and every method and then write the code. Everything is explained inside the code and is very easy to understand. Add below code in your MainActivity.java</p><pre><strong>import </strong>android.support.v7.app.AppCompatActivity;<br><strong>import </strong>android.os.Bundle;<br><strong>import </strong>android.util.Log;<br><strong>import </strong>android.view.View;<br><strong>import </strong>android.widget.Button;<br><strong>import </strong>android.widget.TextView;<br><strong>import </strong>android.widget.Toast;<br><br><em>/*<br> Created by rajat4914 on 04/01/17.<br> */<br><br></em><strong>public class </strong>MainActivity <strong>extends </strong>AppCompatActivity <strong>implements </strong>View.OnClickListener{<br><br>    <em>/*<br>    DESCRIPTION OF VARIABLES<br><br>    TAG ---------&gt; Used for log debugging<br>    PLAYER_X ----&gt; Variable to identify player turn<br>    TURN_COUNT --&gt; Variable to keep count of number of turns<br>    b00 - b22 ---&gt; Button for each 3x3 box<br>    tvInfo ------&gt; Information regarding game status<br>    boardStatus -&gt; 2-d array to identify board status<br>        -1 means, No one has played on that box yet<br>        0 means, Player 0 has played on that box<br>        1 means, Player X has played on that box<br>    */<br><br>    /*<br>    DESCRIPTION OF METHODS<br><br>    onClick --------&gt; Called whenever any box or reset button is clicked.<br>        This method places either X or 0 according to player turn<br>        and updates other information<br><br>    checkWinner ----&gt; This method checks the board status and identifies the winner<br>        It checks for all the 3 rows, 3 columns and 2 diagonals<br><br>    resetBoard -----&gt; This method is called whenever reset button is pressed.<br>        updates everything to initial values of game<br><br>    enableAllBoxes -&gt; This method can either enable or disable all boxes<br><br>    setInfo --------&gt; This method updates the string in TextView<br><br>    result ---------&gt; This method works whenever a player wins or game draws<br><br>    initializeBoardStatus -&gt; Method which set the value of integer array to -1<br><br>    */<br><br>    </em><strong>private final static </strong>String <strong><em>TAG </em></strong>= MainActivity.<strong>class</strong>.getSimpleName();<br>    <strong>boolean PLAYER_X </strong>= <strong>true</strong>;<br><br>    <strong>int TURN_COUNT </strong>= 0;<br><br>    Button <strong>b00</strong>;<br>    Button <strong>b01</strong>;<br>    Button <strong>b02</strong>;<br><br>    Button <strong>b10</strong>;<br>    Button <strong>b11</strong>;<br>    Button <strong>b12</strong>;<br><br>    Button <strong>b20</strong>;<br>    Button <strong>b21</strong>;<br>    Button <strong>b22</strong>;<br><br>    Button <strong>bReset</strong>;<br><br>    TextView <strong>tvInfo</strong>;<br><br>    <strong>int</strong>[][] <strong>boardStatus </strong>= <strong>new int</strong>[3][3];<br><br>    @Override<br>    <strong>protected void </strong>onCreate(Bundle savedInstanceState) {<br>        <strong>super</strong>.onCreate(savedInstanceState);<br>        setContentView(R.layout.<strong><em>activity_main</em></strong>);<br><br>        <strong>b00 </strong>= (Button) findViewById(R.id.<strong><em>b00</em></strong>);<br>        <strong>b01 </strong>= (Button) findViewById(R.id.<strong><em>b01</em></strong>);<br>        <strong>b02 </strong>= (Button) findViewById(R.id.<strong><em>b02</em></strong>);<br><br>        <strong>b10 </strong>= (Button) findViewById(R.id.<strong><em>b10</em></strong>);<br>        <strong>b11 </strong>= (Button) findViewById(R.id.<strong><em>b11</em></strong>);<br>        <strong>b12 </strong>= (Button) findViewById(R.id.<strong><em>b12</em></strong>);<br><br>        <strong>b20 </strong>= (Button) findViewById(R.id.<strong><em>b20</em></strong>);<br>        <strong>b21 </strong>= (Button) findViewById(R.id.<strong><em>b21</em></strong>);<br>        <strong>b22 </strong>= (Button) findViewById(R.id.<strong><em>b22</em></strong>);<br><br>        <strong>bReset </strong>= (Button) findViewById(R.id.<strong><em>bReset</em></strong>);<br>        <strong>tvInfo </strong>= (TextView) findViewById(R.id.<strong><em>tvInfo</em></strong>);<br><br>        <strong>bReset</strong>.setOnClickListener(<strong>this</strong>);<br><br>        <strong>b00</strong>.setOnClickListener(<strong>this</strong>);<br>        <strong>b01</strong>.setOnClickListener(<strong>this</strong>);<br>        <strong>b02</strong>.setOnClickListener(<strong>this</strong>);<br><br>        <strong>b10</strong>.setOnClickListener(<strong>this</strong>);<br>        <strong>b11</strong>.setOnClickListener(<strong>this</strong>);<br>        <strong>b12</strong>.setOnClickListener(<strong>this</strong>);<br><br>        <strong>b20</strong>.setOnClickListener(<strong>this</strong>);<br>        <strong>b21</strong>.setOnClickListener(<strong>this</strong>);<br>        <strong>b22</strong>.setOnClickListener(<strong>this</strong>);<br><br>        initializeBoardStatus();<br><br>    }<br><br>    @Override<br>    <strong>public void </strong>onClick(View view) {<br>        Log.<em>d</em>(<strong><em>TAG</em></strong>, <strong>&quot;Inside onClick&quot;</strong>);<br><br>        <strong>boolean </strong>resetButtonPressed = <strong>false</strong>;<br><br>        <strong>switch </strong>(view.getId()){<br>            <strong>case </strong>R.id.<strong><em>b00</em></strong>:<br>                <strong>if</strong>(<strong>PLAYER_X</strong>){<br>                    <strong>b00</strong>.setText(<strong>&quot;X&quot;</strong>);<br>                    <strong>boardStatus</strong>[0][0] = 1;<br>                }<br>                <strong>else</strong>{<br>                    <strong>b00</strong>.setText(<strong>&quot;0&quot;</strong>);<br>                    <strong>boardStatus</strong>[0][0] = 0;<br>                }<br>                <strong>b00</strong>.setEnabled(<strong>false</strong>);<br>                <strong>break</strong>;<br><br>            <strong>case </strong>R.id.<strong><em>b01</em></strong>:<br>                <strong>if</strong>(<strong>PLAYER_X</strong>){<br>                    <strong>b01</strong>.setText(<strong>&quot;X&quot;</strong>);<br>                    <strong>boardStatus</strong>[0][1] = 1;<br>                }<br>                <strong>else</strong>{<br>                    <strong>b01</strong>.setText(<strong>&quot;0&quot;</strong>);<br>                    <strong>boardStatus</strong>[0][1] = 0;<br>                }<br>                <strong>b01</strong>.setEnabled(<strong>false</strong>);<br>                <strong>break</strong>;<br><br>            <strong>case </strong>R.id.<strong><em>b02</em></strong>:<br>                <strong>if</strong>(<strong>PLAYER_X</strong>){<br>                    <strong>b02</strong>.setText(<strong>&quot;X&quot;</strong>);<br>                    <strong>boardStatus</strong>[0][2] = 1;<br>                }<br>                <strong>else</strong>{<br>                    <strong>b02</strong>.setText(<strong>&quot;0&quot;</strong>);<br>                    <strong>boardStatus</strong>[0][2] = 0;<br>                }<br>                <strong>b02</strong>.setEnabled(<strong>false</strong>);<br>                <strong>break</strong>;<br><br>            <strong>case </strong>R.id.<strong><em>b10</em></strong>:<br>                <strong>if</strong>(<strong>PLAYER_X</strong>){<br>                    <strong>b10</strong>.setText(<strong>&quot;X&quot;</strong>);<br>                    <strong>boardStatus</strong>[1][0] = 1;<br>                }<br>                <strong>else</strong>{<br>                    <strong>b10</strong>.setText(<strong>&quot;0&quot;</strong>);<br>                    <strong>boardStatus</strong>[1][0] = 0;<br>                }<br>                <strong>b10</strong>.setEnabled(<strong>false</strong>);<br>                <strong>break</strong>;<br><br>            <strong>case </strong>R.id.<strong><em>b11</em></strong>:<br>                <strong>if</strong>(<strong>PLAYER_X</strong>){<br>                    <strong>b11</strong>.setText(<strong>&quot;X&quot;</strong>);<br>                    <strong>boardStatus</strong>[1][1] = 1;<br>                }<br>                <strong>else</strong>{<br>                    <strong>b11</strong>.setText(<strong>&quot;0&quot;</strong>);<br>                    <strong>boardStatus</strong>[1][1] = 0;<br>                }<br>                <strong>b11</strong>.setEnabled(<strong>false</strong>);<br>                <strong>break</strong>;<br><br>            <strong>case </strong>R.id.<strong><em>b12</em></strong>:<br>                <strong>if</strong>(<strong>PLAYER_X</strong>){<br>                    <strong>b12</strong>.setText(<strong>&quot;X&quot;</strong>);<br>                    <strong>boardStatus</strong>[1][2] = 1;<br>                }<br>                <strong>else</strong>{<br>                    <strong>b12</strong>.setText(<strong>&quot;0&quot;</strong>);<br>                    <strong>boardStatus</strong>[1][2] = 0;<br>                }<br>                <strong>b12</strong>.setEnabled(<strong>false</strong>);<br>                <strong>break</strong>;<br><br>            <strong>case </strong>R.id.<strong><em>b20</em></strong>:<br>                <strong>if</strong>(<strong>PLAYER_X</strong>){<br>                    <strong>b20</strong>.setText(<strong>&quot;X&quot;</strong>);<br>                    <strong>boardStatus</strong>[2][0] = 1;<br>                }<br>                <strong>else</strong>{<br>                    <strong>b20</strong>.setText(<strong>&quot;0&quot;</strong>);<br>                    <strong>boardStatus</strong>[2][0] = 0;<br>                }<br>                <strong>b20</strong>.setEnabled(<strong>false</strong>);<br>                <strong>break</strong>;<br><br>            <strong>case </strong>R.id.<strong><em>b21</em></strong>:<br>                <strong>if</strong>(<strong>PLAYER_X</strong>){<br>                    <strong>b21</strong>.setText(<strong>&quot;X&quot;</strong>);<br>                    <strong>boardStatus</strong>[2][1] = 1;<br>                }<br>                <strong>else</strong>{<br>                    <strong>b21</strong>.setText(<strong>&quot;0&quot;</strong>);<br>                    <strong>boardStatus</strong>[2][1] = 0;<br>                }<br>                <strong>b21</strong>.setEnabled(<strong>false</strong>);<br>                <strong>break</strong>;<br><br>            <strong>case </strong>R.id.<strong><em>b22</em></strong>:<br>                <strong>if</strong>(<strong>PLAYER_X</strong>){<br>                    <strong>b22</strong>.setText(<strong>&quot;X&quot;</strong>);<br>                    <strong>boardStatus</strong>[2][2] = 1;<br>                }<br>                <strong>else</strong>{<br>                    <strong>b22</strong>.setText(<strong>&quot;0&quot;</strong>);<br>                    <strong>boardStatus</strong>[2][2] = 0;<br>                }<br>                <strong>b22</strong>.setEnabled(<strong>false</strong>);<br>                <strong>break</strong>;<br><br>            <strong>case </strong>R.id.<strong><em>bReset</em></strong>:<br>                resetButtonPressed = <strong>true</strong>;<br>                <strong>break</strong>;<br><br>            <strong>default</strong>:<br>                <strong>break</strong>;<br><br>        }<br><br>        <strong>if</strong>(resetButtonPressed){<br>            resetBoard();<br>        }<br>        <strong>else</strong>{<br>            <strong>TURN_COUNT </strong>++;<br>            <strong>PLAYER_X </strong>= !<strong>PLAYER_X</strong>;<br><br>            <strong>if</strong>(<strong>PLAYER_X</strong>){<br>                setInfo(<strong>&quot;Player X turn&quot;</strong>);<br>            }<br>            <strong>else </strong>{<br>                setInfo(<strong>&quot;Player 0 turn&quot;</strong>);<br>            }<br><br>            <strong>if</strong>(<strong>TURN_COUNT</strong>==9){<br>                result(<strong>&quot;Game Draw&quot;</strong>);<br>            }<br><br>            checkWinner();<br>        }<br>    }<br><br>    <strong>private void </strong>checkWinner(){<br><br>        Log.<em>d</em>(<strong><em>TAG</em></strong>, <strong>&quot;Inside checkWinner&quot;</strong>);<br><br>        <em>//Horizontal --- rows<br>        </em><strong>for</strong>(<strong>int </strong>i=0; i&lt;3; i++){<br>            <strong>if</strong>(<strong>boardStatus</strong>[i][0] == <strong>boardStatus</strong>[i][1] &amp;&amp; <strong>boardStatus</strong>[i][0] == <strong>boardStatus</strong>[i][2]){<br>                <strong>if </strong>(<strong>boardStatus</strong>[i][0]==1){<br>                    result(<strong>&quot;Player X winner\n&quot; </strong>+ (i+1)+<strong>&quot; row&quot;</strong>);<br>                    <strong>break</strong>;<br>                }<br>                <strong>else if </strong>(<strong>boardStatus</strong>[i][0]==0) {<br>                    result(<strong>&quot;Player 0 winner\n&quot; </strong>+ (i+1)+<strong>&quot; row&quot;</strong>);<br>                    <strong>break</strong>;<br>                }<br>            }<br>        }<br><br>        <em>//Vertical --- columns<br>        </em><strong>for</strong>(<strong>int </strong>i=0; i&lt;3; i++){<br>            <strong>if</strong>(<strong>boardStatus</strong>[0][i] == <strong>boardStatus</strong>[1][i] &amp;&amp; <strong>boardStatus</strong>[0][i] == <strong>boardStatus</strong>[2][i]){<br>                <strong>if </strong>(<strong>boardStatus</strong>[0][i]==1){<br>                    result(<strong>&quot;Player X winner\n&quot; </strong>+ (i+1)+<strong>&quot; column&quot;</strong>);<br>                    <strong>break</strong>;<br>                }<br>                <strong>else if </strong>(<strong>boardStatus</strong>[0][i]==0) {<br>                    result(<strong>&quot;Player 0 winner\n&quot; </strong>+ (i+1)+<strong>&quot; column&quot;</strong>);<br>                    <strong>break</strong>;<br>                }<br>            }<br>        }<br><br>        <em>//First diagonal<br>        </em><strong>if</strong>(<strong>boardStatus</strong>[0][0] == <strong>boardStatus</strong>[1][1] &amp;&amp; <strong>boardStatus</strong>[0][0] == <strong>boardStatus</strong>[2][2]){<br>            <strong>if </strong>(<strong>boardStatus</strong>[0][0]==1){<br>                result(<strong>&quot;Player X winner\nFirst Diagonal&quot;</strong>);<br>            }<br>            <strong>else if </strong>(<strong>boardStatus</strong>[0][0]==0) {<br>                result(<strong>&quot;Player 0 winner\nFirst Diagonal&quot;</strong>);<br>            }<br>        }<br><br>        <em>//Second diagonal<br>        </em><strong>if</strong>(<strong>boardStatus</strong>[0][2] == <strong>boardStatus</strong>[1][1] &amp;&amp; <strong>boardStatus</strong>[0][2] == <strong>boardStatus</strong>[2][0]){<br>            <strong>if </strong>(<strong>boardStatus</strong>[0][2]==1){<br>                result(<strong>&quot;Player X winner\nSecond Diagonal&quot;</strong>);<br>            }<br>            <strong>else if </strong>(<strong>boardStatus</strong>[0][2]==0) {<br>                result(<strong>&quot;Player 0 winner\nSecond Diagonal&quot;</strong>);<br>            }<br>        }<br>    }<br><br>    <strong>private void </strong>enableAllBoxes(<strong>boolean </strong>value){<br>        Log.<em>d</em>(<strong><em>TAG</em></strong>, <strong>&quot;Inside enableAllBoxes&quot;</strong>);<br>        <strong>b00</strong>.setEnabled(value);<br>        <strong>b01</strong>.setEnabled(value);<br>        <strong>b02</strong>.setEnabled(value);<br><br>        <strong>b10</strong>.setEnabled(value);<br>        <strong>b11</strong>.setEnabled(value);<br>        <strong>b12</strong>.setEnabled(value);<br><br>        <strong>b20</strong>.setEnabled(value);<br>        <strong>b21</strong>.setEnabled(value);<br>        <strong>b22</strong>.setEnabled(value);<br>    }<br><br>    <strong>private void </strong>result(String winner){<br>        Log.<em>d</em>(<strong><em>TAG</em></strong>, <strong>&quot;Inside result&quot;</strong>);<br><br>        setInfo(winner);<br>        enableAllBoxes(<strong>false</strong>);<br>    }<br><br>    <strong>private void </strong>resetBoard(){<br>        Log.<em>d</em>(<strong><em>TAG</em></strong>, <strong>&quot;Inside resetBoard&quot;</strong>);<br>        <strong>b00</strong>.setText(<strong>&quot;&quot;</strong>);<br>        <strong>b01</strong>.setText(<strong>&quot;&quot;</strong>);<br>        <strong>b02</strong>.setText(<strong>&quot;&quot;</strong>);<br><br>        <strong>b10</strong>.setText(<strong>&quot;&quot;</strong>);<br>        <strong>b11</strong>.setText(<strong>&quot;&quot;</strong>);<br>        <strong>b12</strong>.setText(<strong>&quot;&quot;</strong>);<br><br>        <strong>b20</strong>.setText(<strong>&quot;&quot;</strong>);<br>        <strong>b21</strong>.setText(<strong>&quot;&quot;</strong>);<br>        <strong>b22</strong>.setText(<strong>&quot;&quot;</strong>);<br><br>        enableAllBoxes(<strong>true</strong>);<br><br>        <strong>PLAYER_X </strong>= <strong>true</strong>;<br>        <strong>TURN_COUNT </strong>= 0;<br><br>        initializeBoardStatus();<br><br>        setInfo(<strong>&quot;Start Again!!!&quot;</strong>);<br><br>        Toast.<em>makeText</em>(<strong>this</strong>,<strong>&quot;Board Reset&quot;</strong>,Toast.<strong><em>LENGTH_SHORT</em></strong>).show();<br>    }<br><br>    <strong>private void </strong>setInfo(String text){<br>        <strong>tvInfo</strong>.setText(text);<br>    }<br><br>    <strong>private void </strong>initializeBoardStatus(){<br>        <strong>for</strong>(<strong>int </strong>i = 0; i &lt; 3; i++){<br>            <strong>for</strong>(<strong>int </strong>j = 0; j &lt; 3; j++){<br>                <strong>boardStatus</strong>[i][j] = -1;<br>            }<br>        }<br>    <br>    }<br><br><br>}</pre><p>Your application is complete. But you can also learn Intent, which is used to jump between different activities.</p><p>Right click on <em>app </em>folder and create new activity. Name this activity as FirstScreen. (We will take names of two players from this activity and use them in MainActivity)</p><p>XML code of activity_first_screen.xml</p><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:id=&quot;@+id/activity_first_screen&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    android:gravity=&quot;center&quot;<br>    </strong>&gt;<br><br>    &lt;<strong>EditText<br>        android:id=&quot;@+id/etPlayer1&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:hint=&quot;Enter Player 1 Name&quot;<br>        android:layout_margin=&quot;8dp&quot;<br>        android:padding=&quot;8dp&quot;<br>        android:layout_centerHorizontal=&quot;true&quot;<br>        </strong>/&gt;<br><br>    &lt;<strong>EditText<br>        android:id=&quot;@+id/etPlayer2&quot;<br>        android:layout_below=&quot;@id/etPlayer1&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:hint=&quot;Enter Player 2 Name&quot;<br>        android:layout_margin=&quot;8dp&quot;<br>        android:padding=&quot;8dp&quot;<br>        android:layout_centerHorizontal=&quot;true&quot;<br>        </strong>/&gt;<br><br><br>    &lt;<strong>Button<br>        android:id=&quot;@+id/bPlay&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;PLAY&quot;<br>        android:background=&quot;@color/colorAccent&quot;<br>        android:padding=&quot;8dp&quot;<br>        android:layout_margin=&quot;16dp&quot;<br>        android:textSize=&quot;24sp&quot;<br>        android:textColor=&quot;#FFFFFF&quot;<br>        android:layout_below=&quot;@id/etPlayer2&quot;<br>        android:layout_centerHorizontal=&quot;true&quot;<br>        </strong>/&gt;<br><br><br>&lt;/<strong>RelativeLayout</strong>&gt;</pre><p>Code for FirstScreen.java</p><pre><strong>import </strong>android.content.Intent;<br><strong>import </strong>android.support.v7.app.AppCompatActivity;<br><strong>import </strong>android.os.Bundle;<br><strong>import </strong>android.view.View;<br><strong>import </strong>android.widget.Button;<br><strong>import </strong>android.widget.EditText;<br><br><strong>public class </strong>FirstScreen <strong>extends </strong>AppCompatActivity {<br><br>    @Override<br>    <strong>protected void </strong>onCreate(Bundle savedInstanceState) {<br>        <strong>super</strong>.onCreate(savedInstanceState);<br>        setContentView(R.layout.<strong><em>activity_first_screen</em></strong>);<br><br>        <strong>final </strong>EditText etPlayer1 = (EditText) findViewById(R.id.<strong><em>etPlayer1</em></strong>);<br>        <strong>final </strong>EditText etPlayer2 = (EditText) findViewById(R.id.<strong><em>etPlayer2</em></strong>);<br>        <br>        Button bPlay = (Button) findViewById(R.id.<strong><em>bPlay</em></strong>);<br>        <br>        bPlay.setOnClickListener(<strong>new </strong>View.OnClickListener() {<br>            @Override<br>            <strong>public void </strong>onClick(View view) {<br>                <br>                <em>//Getting strings from edit text<br>                </em>String PLAYER_1 = <strong>&quot;&quot; </strong>+ etPlayer1.getText().toString();<br>                String PLAYER_2 = <strong>&quot;&quot; </strong>+ etPlayer2.getText().toString();<br>                <br>                <em>//Intents are used to shift from one activity to another.<br>                //We can also transfer data with intents.<br>                <br>                //Creating an object of intent through which we can go from current activity to MainAcivity<br>                </em>Intent i = <strong>new </strong>Intent(FirstScreen.<strong>this</strong>,MainActivity.<strong>class</strong>);<br>                <br>                <em>//Adding data with intent to transfer.<br>                </em>i.putExtra(<strong>&quot;PLAYER_1&quot;</strong>,PLAYER_1);<br>                i.putExtra(<strong>&quot;PLAYER_2&quot;</strong>,PLAYER_2);<br>                <br>                <em>//Calling to intent to open MainActivity.<br>                </em>startActivity(i);<br>                <br>            }<br>        });<br>    }<br>}</pre><p>Write this code in MainActivity onCreate Method to get data which was transferred with intent.</p><pre>Intent i = getIntent();<br><br>String player_1 = i.getStringExtra(<strong>&quot;PLAYER_1&quot;</strong>);<br>String player_2 = i.getStringExtra(<strong>&quot;PLAYER_2&quot;</strong>);</pre><p>Now we can use above strings in whichever way we want.</p><p>NOTE: This app does contain some bugs which are there from the point of view of android designing and not from the point of view of game. We will soon make those changes too.</p><p>If you have any suggestions regarding this app or on new blogs that I should write, comment down below.</p><p>Also, as an extension to this app you can try to create <strong>9x9 Tic Tac Toe</strong>, if you want to know more comment down below.</p><p>#AndroidMonk</p><p>#WiseLTeach</p><p>#<a href="http://wiselteach.com/">WiseL</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a56b9e1c6a15" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wiselteach/tic-tac-toe-tablelayout-android-app-androidmonk-a56b9e1c6a15">Tic-Tac-Toe (TableLayout) Android App @AndroidMonk</a> was originally published in <a href="https://medium.com/wiselteach">WiseLTeach</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>