<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hari Lee on Medium]]></title>
        <description><![CDATA[Stories by Hari Lee on Medium]]></description>
        <link>https://medium.com/@leehari007?source=rss-a2aff33760d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*hqSt5SKcVq9c5HdZOH67tA.jpeg</url>
            <title>Stories by Hari Lee on Medium</title>
            <link>https://medium.com/@leehari007?source=rss-a2aff33760d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 13:47:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@leehari007/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What could be the future?]]></title>
            <link>https://leehari007.medium.com/what-could-be-the-future-450e4f602ea4?source=rss-a2aff33760d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/450e4f602ea4</guid>
            <category><![CDATA[politics]]></category>
            <category><![CDATA[government]]></category>
            <category><![CDATA[conservatives]]></category>
            <category><![CDATA[liberalism]]></category>
            <category><![CDATA[social-justice]]></category>
            <dc:creator><![CDATA[Hari Lee]]></dc:creator>
            <pubDate>Tue, 01 Dec 2020 08:03:38 GMT</pubDate>
            <atom:updated>2024-06-27T13:47:26.625Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*L7LlxJT1vV_K3uLRb0bz3g.jpeg" /></figure><p>I have my ideologies, my principles, and my world view, but it is just mine and not yours, and I don’t expect you to fully understand me, but I will try to understand you. Trust me I want to.</p><p>This article will be a long one because there are lots to cover. Let’s break it down one by one. Here we will discuss many things certain connections may not be obvious but it convinced me I hope it will convince you too. What our society needs now more than ever are original thinkers who would question the texts and ideas that we consider normal and break it down, we need to question the system and should be ready to listen to the answers the system has to give.</p><p>This piece began as a simple article about Identity Politics and why I think it is not good for us, but then it elevated to many questions and frankly, I didn’t have answers for many. I tried to do justice to the idea but then there was too much chaos. Let’s go back to my ideas, they were inspired, they didn’t originate in me and that was a problem. Opinions are important, your view of the world is necessary but make sure they are your own.</p><h3>Modern Political Spectrum</h3><p>Left, Center, Right.</p><p>What are these, one is an aim at utopia through any means necessary, followed by the ones who see the utopia but is not sure how to get there, they are conflicted, and lastly the ones who don’t need the utopia but are more elevated by the pursuit of one.</p><p>The primary focus here is to draw a draft of what I think is the way to run a society, to do that we need to understand what are the current driving forces of our society.</p><p>The modern political spectrum is a mutable characteristic, the constant dialog between the left and the right and the center. Sometimes there are revelations and some other times there are bloodsheds. But most of the time this dialog is not a dialog, often it is just obtruding.</p><p>From Nazi Germany to Russian Gulag, we’ve seen what the Alt-Right and the Radical Left are capable of doing if left unchecked.</p><h3>Hierarchy is fundamental</h3><p><em>We are in our classrooms, our teacher is giving out the answer sheets and the topper girl has topped again, she is top of the class. The bell rang, and it is time for sports, the young jock takes the lead now, he is on top, sports time is over, and we move to the arts, the young girl who sat silently till now takes out the sharpest weapon known to mankind and starts slaying, her words could move the world.</em></p><p>The hierarchy of competence is the only hierarchy that I can understand. The notion of governance of any kind should be one that is designed by keeping this in mind all the time.</p><p>The Left often ignores this hierarchy and tends to make decisions that try to invert this hierarchy. The Right will turn this hierarchy of competence into a hierarchy of power and trouble emerges. Keep in mind that I’m referring to the extremes of both ends that is the Radical Left and Alt-Right, the reason I’m only concerned about the extremes is that almost all problems begin at the extremes only.</p><h3>What can we do?</h3><p>Conservatives will be given the power to make decisions and the liberal left will be the opposition. Before you stop reading let me explain. The idea behind good governance is maintaining the status quo and on the side innovating and experimenting with new things that could help the society. What will happen if we have a conservative dominion, then things will be good for a while but eventually everything will stagnate and will result in no liberal ideas taken into consideration, eventually we might end up in a pure meritocratic society.</p><p>What will happen if The Left or Liberals dominate everything, it might result in a complete restructuring of society in a radical way which will end up bad for everyone, this is because we cannot save the world and lead grandeur lifestyles at the same time. This might happen because more than often The Left tends to ignore the hierarchy of competence we discussed earlier.</p><p>I am making a connection between the Left and liberal here because all the intellectual elites today are more ideologically Liberal than the Left. And flushing out leftist ideologies and replacing them with liberal ideas will prove fruitful for society. So my intention here is also to re-define what the West sees as Left.</p><p>So what is the solution for this? We must have not one but two elections. One will be to choose the ruling party and the other to choose the opposition. The ruling party election will be an election conducted among different conservative candidates. The election for the opposition will be conducted among different liberal candidates.</p><p>The opposition will no longer be toothless tigers who are fighting for power in the next election. From now on they don’t have to oppose anything and everything the ruling party says. The sole purpose of the opposition will be to figure out what needs to be done in our society and also to find out how are people affected by the ruling party, based on this they must submit drafts to the ruling party and the ruling party must keep in mind of any radical change that could alter the balance and must figure out a way to implement this gradually into the society. Once this is done eventually the new normal will be set and the conservatives will have no problem escorting it.</p><p>Let me give an example by taking into a common problem faced by our society, accepting Transgenders. The conservative ideology suggests that there are only 2 genders you are either a man or a woman, but a liberal principle in the same issue is that people have individual preferences let it be gender or sexual preference, we as a society must consider inclusion and not avoidance.</p><p>How will we address such an issue in our new system of government? Since the issue we are dealing with is fairly recently brought to mainstream media and politics there are not enough studies and debates conducted on the same topic. The first thing we will do is conduct more extensive studies on this topic, because however important we think curing cancer is, finding a way to help people cope with society is equally important. And we do this by addressing issues like this and studying it. Once the study concludes the liberal opposition can submit a draft to the ruling conservative government, now the government cannot ignore this because there are data and science supporting the argument.</p><p>The opposition can make use of the freedom of expression, speech, and protest to make this happen, if one conservative leader is inconsiderate democracy will dictate his term.</p><p>Freedom of speech, Freedom to practice religion must be kept separate from the state. There shouldn’t be any debates on how one should practice his/her religion, the matter will come under the government when it is a humanitarian issue.</p><p>This is my idea of good governance, I want to know your opinion on the same so if you are ready let’s engage in the comment section.</p><p>Thank you</p><p>Follow my channel for history related content<br><a href="https://youtu.be/FKjeiK6rREY">https://youtu.be/FKjeiK6rREY</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=450e4f602ea4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a web app using Flask.]]></title>
            <link>https://leehari007.medium.com/how-to-create-a-web-app-using-flask-aa4e4f2249e6?source=rss-a2aff33760d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa4e4f2249e6</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Hari Lee]]></dc:creator>
            <pubDate>Thu, 21 May 2020 14:51:53 GMT</pubDate>
            <atom:updated>2020-05-24T19:05:11.101Z</atom:updated>
            <content:encoded><![CDATA[<p>A step by step guide in creating a simple web application using flask.</p><p><strong>What is Flask?</strong></p><p>Flask is a micro web framework written in python. Flask is similar to another python-based framework Django, but Flask is considered more pythonic than Django. Flask is easier to learn than compared to Django.</p><p><strong>Prerequisite</strong></p><ol><li>Install lasted version of python (<a href="https://www.python.org/downloads/">https://www.python.org/downloads/</a>)</li><li>Install any code editor I prefer visual studio code (<a href="https://code.visualstudio.com/download">https://code.visualstudio.com/download</a>)</li><li>Once the visual studio is installed we need to add the python extension in it. Follow the diagrams below.</li></ol><figure><img alt="Search for python and you will find a suitable extension and install it." src="https://cdn-images-1.medium.com/max/310/1*uQvT_hjP8E5JRX5AAGkBPg.png" /></figure><p>Search for python and you will get the extension in the result, you can install it from there.</p><p>Now we can start making the web application.</p><blockquote><em>Want to read this story later? Save it in </em><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=blog&amp;utm_campaign=noteworthy&amp;utm_content=eid7"><em>Journal</em></a><em>.</em></blockquote><p><strong>Note: This tutorial takes you through the journey of how to make a web app using flask, basic knowledge of HTML, CSS is expected.</strong></p><p><strong>Let’s code …</strong></p><p>Step 1: create a new folder for the project and make 2 folders and 1 file in it. Name the folders templates and static, and name the file app.py.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*79G4di_szZegnTmUKaPZcA.png" /></figure><p>Here inside the templates folder we will put all the HTML files and inside the static we will make folders to put our CSS, image, and js files.</p><p>Step 2: Open the app.py file, this file will contain the Flask code of this application. So open this file and write the following lines of code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12a66d153c7fc060cf199b583fceebfe/href">https://medium.com/media/12a66d153c7fc060cf199b583fceebfe/href</a></iframe><p>Here @app.route() is used to specify the route and render_template() is used to load the corresponding HTML file. Here we can see we are trying to load the album.html file, which is not yet created so we will open <strong>templates </strong>folder and make a file named album.html.</p><p><strong>album.html</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d79d0ac751e25066783914fbaba4b9fb/href">https://medium.com/media/d79d0ac751e25066783914fbaba4b9fb/href</a></iframe><p>This is the HTML code that will go into album.html file</p><p>Step 3: <strong>How to load CSS files, image files, etc in flask.</strong></p><p>&lt;link rel=”stylesheet” href=”{{url_for(‘static’, filename=’css/style.css’)}}”&gt;</p><p>this piece of code will load style.css file within css folder within the static folder we created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*PFcRa45wv_ABDas_0ZcoRg.png" /></figure><p>Here as u can see css folder contains css files and img folder contains all the image files used in this example.</p><p><strong>style.css</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63a04e3e8dfebf1aa117c636c474e4cd/href">https://medium.com/media/63a04e3e8dfebf1aa117c636c474e4cd/href</a></iframe><p>This is the styling code that will go into the style.css file.</p><p>We can load an image using this line of code.</p><p>&lt;img src=”{{url_for(‘static’, filename=’img/one.jpg’)}}”&gt;</p><p>Step 4: In order to proceed we will create 2 more HTML files they will be named blog.html, magazine.html.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*eZVJ02o4UnMmAc_FpHHG_g.png" /></figure><p>The following lines of code must be placed inside these files.</p><p><strong>blog.html</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a845fcd9b72abca043039b326461f5d/href">https://medium.com/media/9a845fcd9b72abca043039b326461f5d/href</a></iframe><p><strong>magazine.html</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/111fb0415472d9c9e632d25a401118bb/href">https://medium.com/media/111fb0415472d9c9e632d25a401118bb/href</a></iframe><p>Step 5: Now we will proceed to the app.py file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df79ee9b926f28f22772eef73b04edbc/href">https://medium.com/media/df79ee9b926f28f22772eef73b04edbc/href</a></iframe><p>As u can see here we created separate routes for the HTML pages we created.</p><p>Step 6: Let’s run this and see.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*-E3sUHaYwWXjNvfVl2mowA.png" /></figure><p>Press ctrl+tab+` to open the terminal in windows in visual studio and type python app.py to execute app.py file.</p><p>I hope you followed these steps and was able to run the file and see the result on your browser window.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.loom.com%2Fembed%2F646e960dfef14e4393fba1116e91d389&amp;display_name=Loom&amp;url=https%3A%2F%2Fwww.loom.com%2Fshare%2F646e960dfef14e4393fba1116e91d389&amp;image=https%3A%2F%2Fcdn.loom.com%2Fsessions%2Fthumbnails%2F646e960dfef14e4393fba1116e91d389-00001.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=loom" width="1280" height="960" frameborder="0" scrolling="no"><a href="https://medium.com/media/e67a02954bb68af94b6b13b89f7cefad/href">https://medium.com/media/e67a02954bb68af94b6b13b89f7cefad/href</a></iframe><p>Follow this video to see how to run this application and see the result in the browser.</p><p>Here in this git folder, you can see the whole code for this project,</p><p><a href="https://github.com/harilee1325/web_app_article.git">harilee1325/web_app_article</a></p><p>Follow along for the next article which will show you how you can create a virtual environment for your project and host your project in Heroku.</p><p>Thank you</p><p>📝 Save this story in <a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text">Journal</a>.</p><p>👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. <a href="https://usejournal.com/newsletter/noteworthy-in-tech/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_text">Read the Noteworthy in Tech newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa4e4f2249e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a geofence app in android.]]></title>
            <link>https://leehari007.medium.com/how-to-create-a-geofence-app-in-android-ae456f16c0d0?source=rss-a2aff33760d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae456f16c0d0</guid>
            <category><![CDATA[geofencing]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Hari Lee]]></dc:creator>
            <pubDate>Wed, 13 May 2020 09:49:32 GMT</pubDate>
            <atom:updated>2020-05-24T18:51:27.366Z</atom:updated>
            <content:encoded><![CDATA[<p>A step by step guide in creating a Geofence application in android and making use of BroadcastReciever to start a Service when that location is reached.</p><p><strong>What is </strong><a href="https://developer.android.com/training/location/geofencing"><strong>Geofence</strong></a><strong>?</strong></p><p>A geofence is a virtual perimeter for a real-world geographic area. A geo-fence could be dynamically generated — as in a radius around a point location, or a geo-fence can be a predefined set of boundaries.</p><blockquote><em>Want to read this story later? Save it in </em><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=blog&amp;utm_campaign=noteworthy&amp;utm_content=eid7"><em>Journal</em></a><em>.</em></blockquote><p><strong>How do we make use of this in Android?</strong></p><ol><li>Keep track of movements in and out of a geofence.</li><li>Provide location-based notification.</li><li>Provide real-time guidance via the application.</li></ol><p>the use cases are endless, Enough mumbo jumbo let’s get down to business.</p><p><strong>Prerequisite.</strong></p><ol><li>Knowledge of Java and Android studio.</li><li>Understanding of the working principles of <a href="https://developer.android.com/guide/components/services">services </a>and <a href="https://developer.android.com/guide/components/broadcasts">Broadcasts </a>in android.</li><li>Good understanding of the <a href="https://developer.android.com/guide/components/activities/activity-lifecycle">activity life cycle.</a></li></ol><p><strong>Let’s code…</strong></p><p>Step 1: Create a new empty project and name it anything u want preferably Geofence app.</p><p>Step 2: Add the necessary dependency.</p><p>in your project level Gradle file add this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/784a81255e69fe75cc59c3fa6edb64fa/href">https://medium.com/media/784a81255e69fe75cc59c3fa6edb64fa/href</a></iframe><p>in your app-level Gradle file add these</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a1c80047a90d686e684dc2d3eec38d2/href">https://medium.com/media/2a1c80047a90d686e684dc2d3eec38d2/href</a></iframe><p>Step 3: Now we will open up the main activity and create a geofence area for a set of latitude and longitude with some radius.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/032f23e79378a0acf3a38d1959529dd9/href">https://medium.com/media/032f23e79378a0acf3a38d1959529dd9/href</a></iframe><p>this is how you can add a set of geofence in an ArrayList in case you have multiple Geofences to tend to.</p><p>here we have some important points they are.</p><p>unique id for each Geofence : .setRequestId(“unique id”)</p><p>latitude and longitude in Double format : Double.parseDouble(locationModel.getLat()) Double.parseDouble(locationModel.getLon())</p><p>radius in float format : (float) radius)</p><p>Geofencetype: .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER)</p><p>Geofence type can be enter, exit, etc. I gave enter here so every time a device enters a geofence it will be activated.</p><p>Now we build a Geofence, let’s activate it .</p><p>Step 4: Adding a Geofence to</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efbbf4a6b502d84cd26c1c623abceb6b/href">https://medium.com/media/efbbf4a6b502d84cd26c1c623abceb6b/href</a></iframe><p>These methods as their name suggests will enable you to start or end a geofence action. You can call them whenever necessary as in a button click or in a lifecycle method.</p><p>Step 5: Now we will create a method to listen to geofence and take necessary actions when it is fired.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/843bffd1f6de48efccbe84dcc7e887e1/href">https://medium.com/media/843bffd1f6de48efccbe84dcc7e887e1/href</a></iframe><p>In these methods, we are creating a pendingIntent and waiting for a response from Geofence and once we get the confirmation we fire a Broadcast. <strong>The name if my BrodcastReceiver is MyBroadCastReciever. </strong>You can name your anything.</p><p>Step 6: Creating a BroadcastReceiver.</p><p>Here you need to create a new BroadcastReceiver class and write the following methods in it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86a4cc18dfaf508a9e9a4898b73f00b0/href">https://medium.com/media/86a4cc18dfaf508a9e9a4898b73f00b0/href</a></iframe><p>This here will help you send a notification and start a Service at the same time. If the device targeted is above Android O it will start a foreground service.</p><p>Step 7: Create a class called App and extend from class Application and paste the following code in it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d85e54aea587d589f0843c701e23db9/href">https://medium.com/media/2d85e54aea587d589f0843c701e23db9/href</a></iframe><p>Step 8: Create a Service class and name it anything you want, but appropriate to the function of it. Here I am creating a class called LocationService and show you how you can perform a task on the service.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59ae05fed93ba821d6a5e650149193cf/href">https://medium.com/media/59ae05fed93ba821d6a5e650149193cf/href</a></iframe><p>Here we start a service on the method onStartCommand(). Here we are setting up a notification badge to perform a <strong>foreground service </strong>and at the same time, we are starting a <strong>background</strong> task using <strong>AsyncTask </strong>to perform a download operation.</p><p>Step 9: Add the necessary fields in the Manifest file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1bd93af0b68cbd8b0d728d5c93d2a67/href">https://medium.com/media/e1bd93af0b68cbd8b0d728d5c93d2a67/href</a></iframe><p>All the necessary permissions must be granted and also these necessary fields including maps API key needs to be added.</p><p>And that&#39;s it, you have successfully created a Geofence application. If u have any doubts feel free to share in the comment section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*NApubzo4c9QywD90-6u7Lw.jpeg" /></figure><p>Thank you, hope your learned something new.</p><p>📝 Save this story in <a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text">Journal</a>.</p><p>👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. <a href="https://usejournal.com/newsletter/noteworthy-in-tech/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_text">Read the Noteworthy in Tech newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae456f16c0d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to send Notification from an app in Android Studio.]]></title>
            <link>https://leehari007.medium.com/how-to-send-notification-from-an-app-in-android-studio-d98a559f8a72?source=rss-a2aff33760d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d98a559f8a72</guid>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[android-studio]]></category>
            <dc:creator><![CDATA[Hari Lee]]></dc:creator>
            <pubDate>Sun, 10 May 2020 10:11:33 GMT</pubDate>
            <atom:updated>2020-05-10T10:11:33.907Z</atom:updated>
            <content:encoded><![CDATA[<p>A step by step guide in creating a notification channel and pushing notification via BroadcastReceiver.</p><p><strong>Create a new project</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*5hRwafw6awZNRJRbOMkUbQ.png" /><figcaption>Select an empty activity for now.</figcaption></figure><p>Select the necessary API level on the next page and click finish.</p><p>After the build is finished you will see this screen in android studio, which means you successfully created a new project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B5j3COqkf5sM-HkVd6JFYg.png" /></figure><p><strong>Let’s create a broadcast channel.</strong></p><ol><li>create a new class and name it App and this class should extend the Activity class. (it should like the next image)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*fvSdGhEpug6GReajZeLhAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*_OcMxF9HgQosxPHtkBe9pQ.png" /><figcaption>This is how it should look.</figcaption></figure><p>2. Copy and paste this code in the App class</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/537df1b2efc668eb97f7e12fcd2601a8/href">https://medium.com/media/537df1b2efc668eb97f7e12fcd2601a8/href</a></iframe><p>Now this will create a notification channel for you to send the notification.</p><p>Now we will create the BroadcastRecevier class in which we will write the code for showing the actual notification.</p><p><strong>What is BroadcastReceiver?</strong></p><p>Android apps can send or receive broadcast messages from the Android system and other Android apps, similar to the <a href="https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern">publish-subscribe</a> design pattern. These broadcasts are sent when an event of interest occurs. For example, the Android system sends broadcasts when various system events occur, such as when the system boots up or the device starts charging. Apps can also send custom broadcasts, for example, to notify other apps of something that they might be interested in (for example, some new data has been downloaded).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*DumhUm6WU0BhgYVSUF8y8Q.png" /><figcaption>NotifcatinBroadcaster class</figcaption></figure><p>When we create this class it will contain only the class definition, but we need to override the onReceive() in it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f496bc56869a41982327e6a66c1609f9/href">https://medium.com/media/f496bc56869a41982327e6a66c1609f9/href</a></iframe><p>this is the method that we need to override. Now we will write the code that will be used to fire a notification.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/200ab12d93f2ae36df9a84d3c3193edf/href">https://medium.com/media/200ab12d93f2ae36df9a84d3c3193edf/href</a></iframe><p>Here we created a notification builder object I will walk you through the whole process.</p><p>a. We created a method in onReceive() called it sendNotification() and passed the context of the activity from which it is called.</p><p>b. We create an object for NotificationCompat.Builder class and pass the necessary fields in it, they are</p><p>to set the icon : .setSmallIcon(R.drawable.ic_launcher_background)</p><p>to set the title : .setContentTitle(“This is title”)</p><p>to set the body : .setContentText(“This is the content of the notification”)</p><p>to set the priority : .setPriority(NotificationCompat.PRIORITY_DEFAULT)</p><p>these are the contents of the notification we are planning to make. Believe it or not, the hard part is over now all we have to do is create a scenario in that will fire the notification.</p><p>The use case of this is to show the completion of a certain task or to remind the user of something. The use case here is highly flexible and can be molded to fit any and all scenarios.</p><p><strong>This is the MainActivity</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d005f4fa459e14f5120eb104510ba09/href">https://medium.com/media/2d005f4fa459e14f5120eb104510ba09/href</a></iframe><p>here on click of this button, a broadcast intent is passed which will invoke the onReceive() and will cause the notification to be fired.</p><p><strong>This is activity_main.xml</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e78e1800e3ad1c0f7942de1b08ed598/href">https://medium.com/media/7e78e1800e3ad1c0f7942de1b08ed598/href</a></iframe><p>This right here is the button that will be clicked.</p><p><strong>Before wrapping up, copy and paste this code in the android manifest file.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/305ada39caab4163abb89c2ee6d6b883/href">https://medium.com/media/305ada39caab4163abb89c2ee6d6b883/href</a></iframe><p><strong>Now let’s see how well it works, shall we?</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.loom.com%2Fembed%2F8305b07be6a248dda853aff0743087ca&amp;display_name=Loom&amp;url=https%3A%2F%2Fwww.loom.com%2Fshare%2F8305b07be6a248dda853aff0743087ca&amp;image=https%3A%2F%2Fcdn.loom.com%2Fsessions%2Fthumbnails%2F8305b07be6a248dda853aff0743087ca-00001.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=loom" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/09fbeac699eb32b5eb87af32c096012d/href">https://medium.com/media/09fbeac699eb32b5eb87af32c096012d/href</a></iframe><p><strong>Thank you for following along, hope you learned something new today.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d98a559f8a72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is God real?]]></title>
            <link>https://leehari007.medium.com/is-god-real-f31605510789?source=rss-a2aff33760d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f31605510789</guid>
            <category><![CDATA[life]]></category>
            <category><![CDATA[dogs]]></category>
            <category><![CDATA[religion]]></category>
            <category><![CDATA[belief]]></category>
            <category><![CDATA[faith]]></category>
            <dc:creator><![CDATA[Hari Lee]]></dc:creator>
            <pubDate>Sat, 04 Apr 2020 17:00:42 GMT</pubDate>
            <atom:updated>2024-06-27T13:48:04.349Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xb9ivHxQ9IdDKa-XC_B_7g.jpeg" /></figure><p>Elohim, Adoni, YHWH (Jehovah, Yahweh), Brahma, Shangdi, Baha, Allah these are the various names given to the idea of a monotheistic concept of the god, although Allah in Islam is not considered as the name of God but to god itself.</p><p>Since most of human history, which is only a minute part of the existence of the observable universe, we searched for a higher being to rely in times of hardship and pain. I was discussing with one of my friends about god and she asked me who came up with this idea, and yes if we search history well enough we can come up with some particular time frame for that. But we need not do that, we can think about spiderman or superman, yes superheroes god is a superhero.</p><p>Omnipotent</p><p>Omniscient</p><p>Omnipresent</p><p>A transcendent being pulling the chains, but if we use the wonders of the human brain or use our rational thinking for once we can come to the conclusion that this is not more than a child having an imaginary friend, for the child the friend is as real as the tree outside his house, but as he becomes older he grows out of the notion and will only believe in what he can understand with his senses or which is empirical(at least some of them) but there is an exception.</p><p>I will simplify the above statement, think of unicorns, fairies, Santa, we all know no adult in the right presence of their mind will believe in these ideas, but there is one which is etched into the human brain like a parasite.</p><p>God is here to stay.</p><p>If God is omniscient then one should agree that God is nothing more than a prisoner. I will elaborate on that, if we know what is going to happen then how am I free to choose what is going to happen to me, free will goes right outside the window. So if God knows everything then what he actually is, is a prisoner of his own mind and is quite useless to us frankly.</p><p>Think of the term faith, it means believing in something in the absence of evidence. That is extremely dangerous if we base our life on that notion of faith. Mankind has reached here, in the era of the internet, space travel, medicine, physics and all the things science gave us because some of us were not ready to be slaves of this notion of faith and started questioning things, what happens when there is a question some will try to find answers and with this simple duo in play we cracked most of the ciphers of the observable universe.</p><p>If God has laid down the plans for the universe then why do we pray?</p><p>We know whatever we do, things will happen according to the master plan then why care. There is a belief that is god is the source of all moral obligations, if that is true then god is the evilest creature there is. Let me lay it out for you.</p><p>Every day 43 children are diagnosed with cancer and 12% of them do not survive. The average age of children diagnosed with cancer is 6, what could a child of 6 do that upset God so much that he decided to erase that character from his master plan. This is just one of many arguments against the good nature of God.</p><p>Throughout human history, there were many types of gods. Theism believes that God created and runs the universe. Deism believe in the creator but he is not the one who runs it. Pantheism goes even further to say that God is the universe. The Abrahamic religions such as Islam, Christianity, Judaism, Aristotelian Theology, Dharmic religions all say different Gods and try to believe one is correct and others are wrong, in one sense every human being is an atheist because everyone believes in their God and ignores the rest.</p><p>Great minds like Aristotle have pointed out various philosophical aspects that explain God. But it is never the same. As a man of science, this is what makes me question the belief of God. In the world of science, there is no authority, everything is questioned and things always change because it is proved by evidence unlike the notion of God.</p><p>Having an authority that tells you what to do and what not to is highly dangerous unless you are a child and you are under your parents&#39; care. You should come up with the purpose of your life, the question why are we here is of no relevance because we all must make up our own purposes. If God has assigned us tasks or purposes then think about Hitler, Mao Zedong, Joseph Stalin and some of their kind and then think why God would give them these purposes why not give everyone purposes like that of Gandhi.</p><p>Since we live in a world of mass murder, rape, child abuse, hunger and much more I can surely say that God is neither good nor powerful.</p><p>Thank you.</p><p>Follow my channel for history related content</p><p><a href="https://youtu.be/FKjeiK6rREY">https://youtu.be/FKjeiK6rREY</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f31605510789" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make Network API call in Android.]]></title>
            <link>https://leehari007.medium.com/how-to-make-network-api-call-in-android-397df06ffefb?source=rss-a2aff33760d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/397df06ffefb</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[retrofit]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Hari Lee]]></dc:creator>
            <pubDate>Fri, 30 Aug 2019 21:43:22 GMT</pubDate>
            <atom:updated>2019-08-30T21:43:22.366Z</atom:updated>
            <content:encoded><![CDATA[<p>A simple and easy to understand guide in creating a Network API call in android using Retrofit.</p><h3>What is Retrofit?</h3><p>In <strong>Android</strong>, <strong>Retrofit</strong> is a REST Client for Java and <strong>Android</strong> by Square inc under Apache 2.0 license. It is a simple network library used for network transactions. It makes it relatively easy to retrieve and upload JSON (or other structured data) via a REST-based web service.</p><h3>What is API?</h3><p>If I were to explain about API’s it will go beyond this article so I will give a simple analogy that everyone can understand.</p><p>Consider a vending machine, how does it work and what does it contain. A vending machine contains snacks and drinks similar to a server that contains the data we will need for processing.</p><p>In a vending machine, we put in coins and press certain buttons signifying the specific snack or drink. Similarly to get data from the server we need to specify what we need and this is called a request, what happens to the vending machine once we press these buttons it will give us the corresponding snack, this is called as a response while we are communicating with the server.</p><p>In order to perform this beautiful and very important task, we can make use of many libraries one of which is Retrofit.</p><h3>How to?</h3><ol><li>Create an application as we do normally, just follow the pictorial representation to create a new application.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*ecWc4NVQekyFgLCfoQkXxg.png" /></figure><p>select “Empty Activity” and click next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*MvrCvHlSEL5PYBldNoWSdg.png" /></figure><p>after entering an appropriate name for your application click on finish and wait for the build to complete.</p><p>2. In order to do this task, we will need a dummy REST API you can find many websites that provide this service where they will provide you with some sample API to play with or if you wish to make your own API please refer to <a href="https://medium.com/@leehari007/writing-your-first-api-with-python-flask-2d7c7214b22c">this</a> article to achieve just that.</p><p>for this example, I will be using one such dummy API<br>“ <a href="https://jsonplaceholder.typicode.com/todos/1">https://jsonplaceholder.typicode.com/todos/1</a>” this is the API we will be using for this example.</p><p>3. Open up your activity_main.xml file and write the following code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4383ca53fe2c2c8391025e8d57e4c8c9/href">https://medium.com/media/4383ca53fe2c2c8391025e8d57e4c8c9/href</a></iframe><p>this will now create a button in your application on a click of which we will call the API.</p><p>4. Now before we bind this view with the program we need to have certain prerequisites for Retrofit to work, we need to add certain dependency in order for it to work.</p><p>5. Open your app-level Gradle file and paste the following code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7418df2673ed560aef5939d7170f344f/href">https://medium.com/media/7418df2673ed560aef5939d7170f344f/href</a></iframe><p>6. Now create an Interface and name it APIInterface. Here we will define all the methods (endpoints) that we will use for calling the API for different API we will use different methods and this Interface will help keep track of that.</p><p>7. Create another java class and name it APIClient and paste the following code. This class will create the instance of Retrofit and will be used to define the Base Url and verify the SSL certificate etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98e671b5c0a9c7a1ade0bbbb52232920/href">https://medium.com/media/98e671b5c0a9c7a1ade0bbbb52232920/href</a></iframe><p>8. Now let us define the endpoints inside the Interface we created like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3316b4a33a54b1139c6c6601daf849f/href">https://medium.com/media/f3316b4a33a54b1139c6c6601daf849f/href</a></iframe><p>here “Response” is the POJO class we need to create we will go through that class next, create a class Response and place this code in it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12573562005387eb629cae01e492e2ae/href">https://medium.com/media/12573562005387eb629cae01e492e2ae/href</a></iframe><p>9. Now we are almost set up, but we didn&#39;t do something really important, open up the manifest file and provide internet permission, without this the application will crash.</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;</pre><p>10. Now we will bind the views and on click of the button, we will call the API.<br>Open up MainActivity.java and write the following code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8cc34864f9af3f770bc6b80f2072512b/href">https://medium.com/media/8cc34864f9af3f770bc6b80f2072512b/href</a></iframe><p>here we are just printing a toast message of the response we are getting.</p><p>11. This is the response and we can play with it as much as we want.</p><p>{<br> “userId”: 1,<br> “id”: 1,<br> “title”: “delectus aut autem”,<br> “completed”: false<br>}</p><p>I know it’s not much.</p><p>Thank you for following up in the next article I will cover the topic recycler view and how to get data from API and put it into recycler view.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=397df06ffefb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Barcode Scanner using Android Studio]]></title>
            <link>https://medium.com/analytics-vidhya/creating-a-barcode-scanner-using-android-studio-71cff11800a2?source=rss-a2aff33760d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/71cff11800a2</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[barcode]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Hari Lee]]></dc:creator>
            <pubDate>Sat, 24 Aug 2019 15:07:48 GMT</pubDate>
            <atom:updated>2024-06-27T13:46:29.133Z</atom:updated>
            <content:encoded><![CDATA[<p>Step by step guide to building a barcode scanning application using Android Studio.</p><h3>What is this article about</h3><p>This article will guide you through creating an android application using which you can make use of your mobile camera to scan a barcode and read the data in them.</p><h4>Prerequisite</h4><ol><li>The latest version of <a href="https://www.analyticsvidhya.com/blog/2021/11/how-to-deploy-machine-learningml-model-on-android/?utm_source=Backlink&amp;utm_medium=SEO"><strong>Android Studio</strong></a> installed. ( <a href="https://developer.android.com/studio">download from here</a> )</li><li>A mobile device to test the application. (you can make use of the inbuild android emulator but in some pc, it may cause some issues.)</li><li>Knowledge of java or any <a href="https://www.analyticsvidhya.com/blog/2020/09/object-oriented-programming/?utm_source=Backlink&amp;utm_medium=SEO"><strong>object-oriented programing</strong></a> language.</li></ol><h4>Let’s write some code</h4><ol><li>Create a new application in android studio and name it Barcode Scanner.</li><li>Open up your app-level Gradle file and add the below dependency there.</li></ol><pre>implementation &#39;com.google.android.gms:play-services-vision:11.0.2&#39;</pre><p>3. Now hit on Sync now button and wait for the build to complete. Once the build is complete open up your manifest file and add the necessary permissions.</p><pre>&lt;uses-permission android:name=&quot;android.permission.CAMERA&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;</pre><p>also, add the metadata field in your manifest file, inside the application tag and above the activity tag.</p><pre>&lt;meta-data<br>    android:name=&quot;com.google.android.gms.vision.DEPENDENCIES&quot;<br>    android:value=&quot;barcode&quot; /&gt;</pre><p>here’s a full view of my manifest file</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    package=&quot;com.example.barcodescanner&quot;&gt;<br><br>    &lt;uses-permission android:name=&quot;android.permission.CAMERA&quot; /&gt;<br>    &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;<br><br><br>    &lt;uses-feature<br>        android:name=&quot;android.hardware.camera&quot;<br>        android:required=&quot;true&quot; /&gt;<br><br>    &lt;application<br>        android:allowBackup=&quot;true&quot;<br>        android:icon=&quot;@mipmap/ic_launcher&quot;<br>        android:label=&quot;@string/app_name&quot;<br>        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;<br>        android:supportsRtl=&quot;true&quot;<br>        android:theme=&quot;@style/AppTheme&quot;<br>        tools:ignore=&quot;GoogleAppIndexingWarning&quot;&gt;<br><br>        &lt;!--&lt;provider<br>            &amp;lt;!&amp;ndash;android:name=&quot;androidx.core.content.FileProvider&quot;<br>            android:authorities=&quot;com.example.barcodescanner.fileprovider&quot;<br>            android:exported=&quot;false&quot;<br>            android:grantUriPermissions=&quot;true&quot;&gt;&amp;ndash;&amp;gt;<br><br>        &lt;/provider&gt;--&gt;<br>    &lt;meta-data<br>        android:name=&quot;com.google.android.gms.vision.DEPENDENCIES&quot;<br>        android:value=&quot;barcode&quot; /&gt;<br><br>        &lt;activity android:name=&quot;.MainActivity&quot;&gt;<br>            &lt;intent-filter&gt;<br>                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;<br><br>                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;<br>            &lt;/intent-filter&gt;<br>        &lt;/activity&gt;<br>    &lt;/application&gt;<br><br>&lt;/manifest&gt;</pre><p>4. Now you have set up all the dependency needed for the barcode scanner to work and all the permission necessary. Let’s build the UI for the app.</p><p>5. Open your activity_main.xml file and write the below code inside.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    tools:context=&quot;.MainActivity&quot;&gt;<br><br>    &lt;SurfaceView<br>        android:id=&quot;@+id/surface_view&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;300dp&quot;<br>        app:layout_constraintTop_toTopOf=&quot;parent&quot;<br>        app:layout_constraintLeft_toLeftOf=&quot;parent&quot;<br>        app:layout_constraintRight_toRightOf=&quot;parent&quot;<br>        android:layout_marginTop=&quot;100dp&quot;<br>        /&gt;<br><br>    &lt;TextView<br>        android:id=&quot;@+id/barcode_text&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;50dp&quot;<br>        android:layout_marginLeft=&quot;30dp&quot;<br>        android:layout_marginRight=&quot;30dp&quot;<br>        app:layout_constraintTop_toBottomOf=&quot;@id/surface_view&quot;<br>        android:layout_marginTop=&quot;50dp&quot;<br>        android:text=&quot;Barcode Text&quot;<br>        android:textSize=&quot;25sp&quot;<br>        android:padding=&quot;5dp&quot;/&gt;<br><br>&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;</pre><p>Now your view should look something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*zAP3ktXFukyDnnPKRXF-Tg.jpeg" /></figure><p>here we have something called a sufaceview in android and a textview field to display the text scanned by the barcode.</p><p>SurfaceView: It provides a dedicated drawing surface embedded inside the view hierarchy.</p><p>You have completed the UI code for the Barcode App, now let&#39;s write the java code to make wonders happen.</p><p>6. Open MainActivity.java file and you will see the following code.</p><pre>public class MainActivity extends AppCompatActivity {<br>@Override<br>protected void onCreate(Bundle savedInstanceState) {<br>    super.onCreate(savedInstanceState);<br>    setContentView(R.layout.<em>activity_main</em>);<br>}</pre><p>let&#39;s add some code of our own</p><p>7. First, we need to bind the views.</p><pre>public class MainActivity extends AppCompatActivity {<br><br><br>    private SurfaceView surfaceView;<br>    private BarcodeDetector barcodeDetector;<br>    private CameraSource cameraSource;<br>    private static final int <em>REQUEST_CAMERA_PERMISSION </em>= 201;<br>    //This class provides methods to play DTMF tones<br>    private ToneGenerator toneGen1;<br>    private TextView barcodeText;<br>    private String barcodeData;<br><br><br><br>    @Override<br>    protected void onCreate(Bundle savedInstanceState) {<br>        super.onCreate(savedInstanceState);<br>        setContentView(R.layout.<em>activity_main</em>);<br>        toneGen1 = new ToneGenerator(AudioManager.<em>STREAM_MUSIC</em>,     100);<br>        surfaceView = findViewById(R.id.<em>surface_view</em>);<br>        barcodeText = findViewById(R.id.<em>barcode_text</em>);<br>    }</pre><p>8. Now we will write the method to scan the image for a barcode.</p><pre>private void initialiseDetectorsAndSources() {<br><br>    //Toast.makeText(getApplicationContext(), &quot;Barcode scanner started&quot;, Toast.LENGTH_SHORT).show();<br><br>    barcodeDetector = new BarcodeDetector.Builder(this)<br>            .setBarcodeFormats(Barcode.<em>ALL_FORMATS</em>)<br>            .build();<br><br>    cameraSource = new CameraSource.Builder(this, barcodeDetector)<br>            .setRequestedPreviewSize(1920, 1080)<br>            .setAutoFocusEnabled(true) //you should add this feature<br>            .build();<br><br>    surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {<br>        @Override<br>        public void surfaceCreated(SurfaceHolder holder) {<br>            try {<br>                if (ActivityCompat.<em>checkSelfPermission</em>(MainActivity.this, Manifest.permission.<em>CAMERA</em>) == PackageManager.<em>PERMISSION_GRANTED</em>) {<br>                    cameraSource.start(surfaceView.getHolder());<br>                } else {<br>                    ActivityCompat.<em>requestPermissions</em>(MainActivity.this, new<br>                            String[]{Manifest.permission.<em>CAMERA</em>}, <em>REQUEST_CAMERA_PERMISSION</em>);<br>                }<br><br>            } catch (IOException e) {<br>                e.printStackTrace();<br>            }<br><br><br>        }<br><br>        @Override<br>        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {<br>        }<br><br>        @Override<br>        public void surfaceDestroyed(SurfaceHolder holder) {<br>            cameraSource.stop();<br>        }<br>    });<br><br><br>    barcodeDetector.setProcessor(new Detector.Processor&lt;Barcode&gt;() {<br>        @Override<br>        public void release() {<br>            // Toast.makeText(getApplicationContext(), &quot;To prevent memory leaks barcode scanner has been stopped&quot;, Toast.LENGTH_SHORT).show();<br>        }<br><br>        @Override<br>        public void receiveDetections(Detector.Detections&lt;Barcode&gt; detections) {<br>            final SparseArray&lt;Barcode&gt; barcodes = detections.getDetectedItems();<br>            if (barcodes.size() != 0) {<br><br><br>                barcodeText.post(new Runnable() {<br><br>                    @Override<br>                    public void run() {<br><br>                        if (barcodes.valueAt(0).email != null) {<br>                            barcodeText.removeCallbacks(null);<br>                            barcodeData = barcodes.valueAt(0).email.address;<br>                            barcodeText.setText(barcodeData);<br>                            toneGen1.startTone(ToneGenerator.<em>TONE_CDMA_PIP</em>, 150);<br>                        } else {<br><br>                            barcodeData = barcodes.valueAt(0).displayValue;<br>                            barcodeText.setText(barcodeData);<br>                            toneGen1.startTone(ToneGenerator.<em>TONE_CDMA_PIP</em>, 150);<br><br>                        }<br>                    }<br>                });<br><br>            }<br>        }<br>    });<br>}</pre><p>this method will help us scan and display the text in the textview we created in the XML file.</p><p>9. The complete java code will look something like this.</p><pre>package com.example.barcodescanner;<br><br>import androidx.appcompat.app.AppCompatActivity;<br>import androidx.core.app.ActivityCompat;<br><br>import android.Manifest;<br>import android.content.pm.PackageManager;<br>import android.media.AudioManager;<br>import android.media.ToneGenerator;<br>import android.os.Bundle;<br>import android.util.SparseArray;<br>import android.view.SurfaceHolder;<br>import android.view.SurfaceView;<br>import android.widget.TextView;<br><br>import com.google.android.gms.vision.CameraSource;<br>import com.google.android.gms.vision.Detector;<br>import com.google.android.gms.vision.barcode.Barcode;<br>import com.google.android.gms.vision.barcode.BarcodeDetector;<br><br>import java.io.IOException;<br><br>public class MainActivity extends AppCompatActivity {<br><br><br>    private SurfaceView surfaceView;<br>    private BarcodeDetector barcodeDetector;<br>    private CameraSource cameraSource;<br>    private static final int <em>REQUEST_CAMERA_PERMISSION </em>= 201;<br>    private ToneGenerator toneGen1;<br>    private TextView barcodeText;<br>    private String barcodeData;<br><br><br><br>    @Override<br>    protected void onCreate(Bundle savedInstanceState) {<br>        super.onCreate(savedInstanceState);<br>        setContentView(R.layout.<em>activity_main</em>);<br>        toneGen1 = new ToneGenerator(AudioManager.<em>STREAM_MUSIC</em>, 100);<br>        surfaceView = findViewById(R.id.<em>surface_view</em>);<br>        barcodeText = findViewById(R.id.<em>barcode_text</em>);<br>        initialiseDetectorsAndSources();<br>    }<br><br>    private void initialiseDetectorsAndSources() {<br><br>        //Toast.makeText(getApplicationContext(), &quot;Barcode scanner started&quot;, Toast.LENGTH_SHORT).show();<br><br>        barcodeDetector = new BarcodeDetector.Builder(this)<br>                .setBarcodeFormats(Barcode.<em>ALL_FORMATS</em>)<br>                .build();<br><br>        cameraSource = new CameraSource.Builder(this, barcodeDetector)<br>                .setRequestedPreviewSize(1920, 1080)<br>                .setAutoFocusEnabled(true) //you should add this feature<br>                .build();<br><br>        surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {<br>            @Override<br>            public void surfaceCreated(SurfaceHolder holder) {<br>                try {<br>                    if (ActivityCompat.<em>checkSelfPermission</em>(MainActivity.this, Manifest.permission.<em>CAMERA</em>) == PackageManager.<em>PERMISSION_GRANTED</em>) {<br>                        cameraSource.start(surfaceView.getHolder());<br>                    } else {<br>                        ActivityCompat.<em>requestPermissions</em>(MainActivity.this, new<br>                                String[]{Manifest.permission.<em>CAMERA</em>}, <em>REQUEST_CAMERA_PERMISSION</em>);<br>                    }<br><br>                } catch (IOException e) {<br>                    e.printStackTrace();<br>                }<br><br><br>            }<br><br>            @Override<br>            public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {<br>            }<br><br>            @Override<br>            public void surfaceDestroyed(SurfaceHolder holder) {<br>                cameraSource.stop();<br>            }<br>        });<br><br><br>        barcodeDetector.setProcessor(new Detector.Processor&lt;Barcode&gt;() {<br>            @Override<br>            public void release() {<br>                // Toast.makeText(getApplicationContext(), &quot;To prevent memory leaks barcode scanner has been stopped&quot;, Toast.LENGTH_SHORT).show();<br>            }<br><br>            @Override<br>            public void receiveDetections(Detector.Detections&lt;Barcode&gt; detections) {<br>                final SparseArray&lt;Barcode&gt; barcodes = detections.getDetectedItems();<br>                if (barcodes.size() != 0) {<br><br><br>                    barcodeText.post(new Runnable() {<br><br>                        @Override<br>                        public void run() {<br><br>                            if (barcodes.valueAt(0).email != null) {<br>                                barcodeText.removeCallbacks(null);<br>                                barcodeData = barcodes.valueAt(0).email.address;<br>                                barcodeText.setText(barcodeData);<br>                                toneGen1.startTone(ToneGenerator.<em>TONE_CDMA_PIP</em>, 150);<br>                            } else {<br><br>                                barcodeData = barcodes.valueAt(0).displayValue;<br>                                barcodeText.setText(barcodeData);<br>                                toneGen1.startTone(ToneGenerator.<em>TONE_CDMA_PIP</em>, 150);<br><br>                            }<br>                        }<br>                    });<br><br>                }<br>            }<br>        });<br>    }<br><br><br>    @Override<br>    protected void onPause() {<br>        super.onPause();<br>        getSupportActionBar().hide();<br>        cameraSource.release();<br>    }<br><br>    @Override<br>    protected void onResume() {<br>        super.onResume();<br>        getSupportActionBar().hide();<br>        initialiseDetectorsAndSources();<br>    }<br><br>}</pre><p>Now try scanning this barcode and you will see the value that is embedded in the barcode in the textview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LJHoB-2ybBef3RV8LV3OcA.png" /></figure><p>The final screen should something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*BokiEQk-z-4ho9crFIz-nQ.jpeg" /></figure><h3>Thank you.</h3><p>Follow my channel for history related content</p><p><a href="https://youtu.be/FKjeiK6rREY">https://youtu.be/FKjeiK6rREY</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71cff11800a2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/creating-a-barcode-scanner-using-android-studio-71cff11800a2">Creating a Barcode Scanner using Android Studio</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing your first API with Python Flask.]]></title>
            <link>https://leehari007.medium.com/writing-your-first-api-with-python-flask-2d7c7214b22c?source=rss-a2aff33760d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d7c7214b22c</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[flask]]></category>
            <dc:creator><![CDATA[Hari Lee]]></dc:creator>
            <pubDate>Fri, 23 Aug 2019 16:21:38 GMT</pubDate>
            <atom:updated>2019-08-23T16:33:16.882Z</atom:updated>
            <content:encoded><![CDATA[<p>Step by step guide to building a simple GET and POST method using python flask.</p><h3>What is this article about</h3><p>This article will take you through the steps in creating a simple flask application and write your own API for the application you are building.</p><p>I myself am a frontend developer, so I am familiar with the issues any front-end developer would face while trying to migrate to writing API’s or trying to get into the backend development. Teaching all the aspects of creating a strong backend code is beyond the scope of this article but this could serve as the right ignition to achieve just that.</p><h3>Technical Requirements</h3><ol><li>any code editor (I personally prefer visual studio code)</li><li>the latest version of python installed (<a href="https://www.python.org/downloads/">find the link here</a>)</li></ol><h4><strong>Let’s write some code</strong></h4><ol><li>Create a new project name it “Flask_program”.</li><li>Create a file inside and name it “app.py”.</li><li>Now open up your command prompt and direct to the folder where your project is placed (if you are using visual studio code press CTRL and ` button to open up the inbuilt command prompt).</li><li>Write pip install flask to install flask in your project.</li><li>Once the installation is completed open up the project in visual studio code.</li><li>Open app.py and write the following code.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50eb774c189ae8e599f3f607ca8bddab/href">https://medium.com/media/50eb774c189ae8e599f3f607ca8bddab/href</a></iframe><p>4. Now run the command “python app.py” in the command prompt you should be able to see a set of comments appearing in the command prompt like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*syrHQt8qP7oSIj1FP_Pkog.png" /></figure><p>5. Now simply open up your browser and search localhost and you will be able to see your program executing.</p><h3>Creating a GET method</h3><p>A GET method is used to carry data from the client to server in the HTTP protocol, a GET method carries request parameters appended in the URL.</p><h4>let&#39;s see how it is done.</h4><ol><li>Continue in the same folder and add the following code in the file app.py you created.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/224a60bf49563ef6c5944ab408ed055d/href">https://medium.com/media/224a60bf49563ef6c5944ab408ed055d/href</a></iframe><p>2. After writing the following code run the program like before.</p><p>3. This time in order to see the route in action you can either use postman or simply got to the browser and hit the URL</p><p>4. Open up your browser and type the URL “ <a href="http://localhost:5000/login/username/password">http://localhost:5000/login/username/password</a>”.</p><p>here in place of username and password give any string of your choice, remember we discussed earlier that a GET method is one that accepts parameters appended in the URL, that is what we are doing here.</p><p>Give yourself a nice pat you have successfully written a GET method in python flask.</p><h3>Creating a POST method</h3><p>A POST method is used to carry data from the client to the server in the body of the URL rather than embedded in the URL itself.</p><h4>let’s see how it is done.</h4><ol><li>Continue in the same folder and add the following code in the file app.py you created.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb827d15761fc6d1f690534e84c5d7bb/href">https://medium.com/media/bb827d15761fc6d1f690534e84c5d7bb/href</a></iframe><p>2. The above code guides you in writing a POST method and execute it the same way.</p><p>3. In order to test this route, we will make use of an application called postman( <a href="https://www.getpostman.com/downloads/">download postman here</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJBUntfQ0g0gNHEtHx6lPg.png" /></figure><p>4. Make sure that you spell it correctly.</p><h4>Conclusion</h4><p>You can now play with the above code snippet and make wonders happen.</p><h3>Thank you.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d7c7214b22c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>