{"id":6286,"date":"2025-03-13T12:39:58","date_gmt":"2025-03-13T12:39:58","guid":{"rendered":"https:\/\/obsidiansofteducation.com\/?page_id=6286"},"modified":"2025-03-13T12:40:10","modified_gmt":"2025-03-13T12:40:10","slug":"prayer-times-app-in-mit-app-inventor","status":"publish","type":"page","link":"https:\/\/obsidiansofteducation.com\/index.php\/prayer-times-app-in-mit-app-inventor\/","title":{"rendered":"Prayer Times App in MIT App Inventor"},"content":{"rendered":"\n<p class=\"has-medium-font-size\">Hello friends! Welcome to Obsidian Soft!<\/p>\n\n\n\n<p class=\"has-medium-font-size\">\ud83c\udf19 Ramadan has begun in the Islamic world, and this year, I have an exciting new project for you! Last year, I showed you how to build a Qibla Compass app, and this time, we are creating a Prayer Timings app in MIT App Inventor! \ud83d\udcf1\u2728<\/p>\n\n\n\n<p class=\"has-medium-font-size\">This idea was highly requested by many of my viewers, and it is a great way to impress your friends, teachers, or even add to your portfolio!<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong><br><\/strong>In my previous <a href=\"https:\/\/obsidiansofteducation.com\/index.php\/weather-app-in-mit-app-inventor\/\">weather app tutorial<\/a>, users had to enter their city manually. But this time, we are making it even smarter! \ud83d\ude80<\/p>\n\n\n\n<p class=\"has-medium-font-size\">\u2705 Using the Location Sensor, the app will automatically detect the user&#8217;s longitude and latitude.<br>\u2705 We will send this data to an API (Adhan.com) to get accurate prayer timings.<br>\u2705 Since prayer times vary based on schools of thought (Shafi, Hanafi, Jafari), we will allow users to select their preferred school.<br>\u2705 For Shafi and Hanafi, we will use the Muslim World League (MWL) method. <strong><br><\/strong>We will be working with this API:<a href=\"https:\/\/aladhan.com\/prayer-times-api#get-\/timings\/-date-\" target=\"_blank\" rel=\"noopener\">https:\/\/aladhan.com\/prayer-times-api#get-\/timings\/-date-<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Now, let\u2019s begin. Open up MIT App Inventor. Go to projects. Start a new project. Let\u2019s name it PrayerTimingsApp. Keep the toolkit default (super important).<\/p>\n\n\n\n<p class=\"has-medium-font-size\">For Screen1, make align horizontal center. Make the background color a custom dark green. Change title text to \u201cPrayer Timings\u201d. From user interface, drag and drop a spinner onto the viewer. Rename it to schoolPicker. Drag and drop a listview below this spinner.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">&nbsp;We also need some non-visible components:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">\u00a0A location sensor from sensors palette.\u00a0<\/li>\n\n\n\n<li class=\"has-medium-font-size\">A web component from connectivity and\u00a0<\/li>\n\n\n\n<li class=\"has-medium-font-size\">A tinyDB from storage for saving our preferred school.<\/li>\n<\/ol>\n\n\n\n<p class=\"has-medium-font-size\">Our simple screen design is done so let\u2019s go to the blocks section.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">We need 4 global variables:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/03\/AD_4nXep_4xMtfskaa3hAADbc8bOnq3rI8ExKFi_xK61V_nHYZC-SJP8UD_wWx1MWxnN-l4v2isL8ZcNAaZ8t6JVqGhJtp9TGQZFAEW89f77g0Y6fxc0ReknsUHbPRyp0WP-taKDjSKy1wkey5lPF5Nc-6KX9E4VvLSzPZ0j1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">When the screen is initialized, fill up the schools list with 3 prominent Muslim schools of thought: Shafi, Hanafi and Jafari. Provide this list of schools to the school picker spinner. Also, load the chosen school from TinyDB. By default, it will be Shafi. This will be the case if the app is being used for the first time. Also, provide the chosen school to the spinner\u2019s selection so that it is preselected.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/03\/AD_4nXe8rnx3LyhMfbnnjk5_YtTDikQ1SnyGcFC628YvYigCN8vGTvD5z4IWDvnt9qp-j88NshRxks5c6S-zWYMSVhb3xjC2Yu2I56-gJxmdPTRHSf-Jw3LrCxRFLrs7d5E0WusHBBeOFgkey5lPF5Nc-6KX9E4VvLSzPZ0j1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Next, make an empty procedure for getting prayer timings.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/03\/AD_4nXcS_eW6k_GmFQaPTpbnqx-YVA8-PzoXhPidBvU3mzPBHfxd3vO2ircZX4jIZkEGXNden_Ifb_66_QalxbqmnQIUrEOgZYO14rtaF-ap4wpIjeL1A87lWgWXqMonkY9RvGeC39Bwwkey5lPF5Nc-6KX9E4VvLSzPZ0j1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Go to location sensor and get its location changed event. Call the getPrayerTimes procedure whenever location changed event is triggered.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"449\" height=\"116\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/03\/AD_4nXfKj5SDnOqnVm-WiEYCE94LIICxWKWxtCqpDyXeEtDKODHvYj4e3-wSxpVRu7wmUCRV2FOu278qoL5clLk71Kq4Ul_tcZsZcILoaospOzJMIfBf7sKaKmqSyNSh8e8WIBxaPEcxAkey5lPF5Nc-6KX9E4VvLSzPZ0j1.png\"><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Now, let\u2019s work on the getPrayerTimes procedure. We set web1.url to a join of 4 things.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"has-medium-font-size\"><a href=\"https:\/\/api.aladhan.com\/v1\/timings?latitude=\" target=\"_blank\" rel=\"noopener\">https:\/\/api.aladhan.com\/v1\/timings?latitude=<\/a><\/li>\n\n\n\n<li class=\"has-medium-font-size\">Location sensor\u2019s latitude<\/li>\n\n\n\n<li class=\"has-medium-font-size\">&amp;longitude=<\/li>\n\n\n\n<li class=\"has-medium-font-size\">Location sensor\u2019s longitude<\/li>\n<\/ol>\n\n\n\n<p class=\"has-medium-font-size\">Be careful with the spellings.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/03\/AD_4nXc-CAuRWvkScRSJsgiDF3nYCzzdFKAOpRdksz4OWBkAk1J13G6gxVstsN_66MgcrNbxveh8NGrsSefdhT9PiInw28z8sofJKg8Fq4SHcPclJRS-ZJQsxmpybhKjTBAdK8xfnFDxnwkey5lPF5Nc-6KX9E4VvLSzPZ0j1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Add an if\/else if\/else block from control.&nbsp;<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Check selection of school picker and choose method\/school accordingly.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">After this call, web1.Get.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">You can change method =3 for shafi and hanafi. Method 3 here means Muslim World League which I thought is a more universal method but you can go for ISNA too by making method =2.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">For Jafari i.e. Shia school , the method will be 0 and we will not provide a school.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/03\/AD_4nXcei4HuxUpsZcsOl9DuwDjiHXBf0CQIu3uDKbVglEnHqbDb94Wg6zDoUpgSVAozVdtwmKQzFwDOOcr3OyD8FIyxfhcrPMCdFKrNI87bHqfbZGI9hcnDdLm73fWQjNibXj_x8YKBkey5lPF5Nc-6KX9E4VvLSzPZ0j1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Now, let\u2019s work on the final part i.e. the Web1.gotText event where will decode the responseContent returned by API. let\u2019s build it up slowly.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">First, get the event and check that the responseCode =200. This means that there was no error from the API.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/03\/AD_4nXev_L9QcT80eNNWhZGllaggeHUudLHBU0MB2k7rAy6SfjUsFatu0a9-z8O0yZUmDI0cgxofAfgvfLDGcqsQoQYNV3XZ4kkykPQ4_iqFwLK-ammER7LkxGiQBO7UrfnIgnIh7wmXkey5lPF5Nc-6KX9E4VvLSzPZ0j1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Next, call Web1. JsonTextDecodeWithDictionaries procedure to decode the responseContent into a local variable called json.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/03\/AD_4nXcLLqvste3tfAlCruoR3Xn2Yb013KpHMGuPughhlFJjuLNVlX7cSLIfLzoZcw7myqYBW6G0n12eVVXPbVC86WNgrgoDUR_FbT8-GvF2IJ4e09pM8Sr0j7eUyw-isPHeDxmWULFi7Akey5lPF5Nc-6KX9E4VvLSzPZ0j1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Inside the local variable block, set the prayersDict by first getting the dictionary against key <strong><a href=\"https:\/\/obsidiansofteducation.com\/index.php\/weather-app-in-mit-app-inventor\/\">data <\/a><\/strong>from <strong>json <\/strong>dictinary and then using this dictionary to get dictionary against key <strong>timings<\/strong>. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/03\/AD_4nXfz_vWKntiMAkoknFJknQo3xmb667_HyFGJ-dDfhbYSODUp-sSkwBlHrOva-1TEISO2OfncoIj0uVx0ejBjkPOQEUMhV2zxxH8j9HZmgEo8rX5M3ock3Cb_bTqHpdqHh0w-dVuxhAkey5lPF5Nc-6KX9E4VvLSzPZ0j1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Now, start getting prayer times for each prayer and adding each item to the prayerTimings list. At the end, provide this list to listview\u2019s elements. I copy pasted the prayer names from the API to avoid spelling mistakes. The key has to be exactly the same as given below to get the timings.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/03\/AD_4nXc79EcboTzppzKv_XnBe4RD4wFW0U6laB2yOMTROJBjpgfeFOWm0rin7S9__hov_Qi1KLU07-Xk6GZazMEzE-TXsTA5GzmRjJ9CjlMqkwGO4hKRWUktNXe_W95CP_9769BIpgWhVgkey5lPF5Nc-6KX9E4VvLSzPZ0j1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">And we are done. This simple but elegant Prayer Timings app is done. I hope you enjoy making this app and customizing it with labels etc. as I know I have kept the screen design quite simple.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">You can also check out the video tutorial here:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<p class=\"responsive-video-wrap clr\"><iframe loading=\"lazy\" title=\"Prayer Timings App for MIT App Inventor | App inventor Tutorial for Prayer Times | #ramadan #namaz\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/JMX5HW0GMU0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<\/div><\/figure>\n\n\n\n<p class=\"has-medium-font-size\">Do like the video and share with friends and family and if you haven\u2019t subscribed to my channel, kindly do so so that you don\u2019t miss the great projects that I have planned for you. Thank you for watching. Ramadan Mubarak. Have a good day and good bye.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Please like my videos and share them with your friends and family. Also, subscribe to my channel and press the bell icon so you don\u2019t miss any of the great projects I have planned for you.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><a href=\"https:\/\/www.youtube.com\/c\/obsidiansofteducation\" target=\"_blank\" rel=\"noopener\">https:\/\/www.youtube.com\/c\/obsidiansofteducation<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Please like my social media pages for more educational resources and tips.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Facebook:<a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.facebook.com\/ObsidianSoft\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Instagram:<a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.instagram.com\/obsidiansoftapps\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">For links to free educational apps, have a look at the\u00a0<a href=\"https:\/\/obsidiansofteducation.com\/index.php\/mobile-apps\/\">educational apps page<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\">Pinterest: <a href=\"https:\/\/www.pinterest.com\/obsidiansoft\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.pinterest.com\/obsidiansoft\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello friends! Welcome to Obsidian Soft! \ud83c\udf19 Ramadan has begun in the Islamic world, and this year, I have an exciting new project for you! Last year, I showed you how to build a Qibla Compass app, and this time, we are creating a Prayer Timings app in MIT App Inventor! \ud83d\udcf1\u2728 This idea was [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-6286","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/comments?post=6286"}],"version-history":[{"count":1,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6286\/revisions"}],"predecessor-version":[{"id":6297,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6286\/revisions\/6297"}],"wp:attachment":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/media?parent=6286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}